-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve failure message for the Babel plugin (#2269)
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/babel-plugin-orbit-components/scripts/testRequire.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @noflow | ||
|
||
// to avoid an ESLint issue with --report-unused-disable-directives | ||
const path = "../dist"; | ||
|
||
try { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
require(path); | ||
} catch (err) { | ||
const match = err.message.match(/Cannot find module '([^']*\/(\w+))'/); | ||
if (match) { | ||
console.error( | ||
`\n@kiwicom/babel-plugin-orbit-components did not correctly transform the import path for the module "${match[2]}", "${match[1]}" doesn't exist. Make sure to configure it properly.\n`, | ||
); | ||
} else { | ||
console.error(err); | ||
} | ||
process.exit(1); | ||
} |