-
Notifications
You must be signed in to change notification settings - Fork 83
Add 'require' flag to preload JS modules #83
Conversation
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
===========================================
- Coverage 92.7% 80.49% -12.21%
===========================================
Files 7 7
Lines 274 282 +8
===========================================
- Hits 254 227 -27
- Misses 20 55 +35
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be a win for folks 🎉 thanks for putting it together
we'll need package-lock.json
removed from the commit - that's something we maintain during publish because it's messy
and we'll need a test or two added to cli.js
to make sure this doesn't break unexpectedly in the future.
cli.js
Outdated
@@ -68,7 +94,7 @@ const { config } = explorer.load() || {}; | |||
const options = merge({ flags }, config); | |||
|
|||
if (cli.input.length) { | |||
[flags.config] = cli.input; | |||
flags.config = cli.input[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change? pretty sure that fails linting due to the prefer-destructuring
rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is using ES6 features for nothing. It is a clever trick but does not improve readability and may be confusing for JS beginners. I've reverted this change.
d3e9473
to
d323889
Compare
d323889
to
64f7f3d
Compare
4e0343f
to
3f4bfb2
Compare
@ooflorent I wonder if we could mock What I'm thinking is that we mock that module before requiring cosmiconfig, if the |
That could work but it's hacky. Another option is to replace |
|
@shellscape If you PR something, I'll be glad to review it ;) |
This PR contains a:
Motivation / Use-Case
Add
--require
flag (and its alias-r
) to preload JS modules. The flag could be added multiple times to load multiple modules.Breaking Changes
none
Additional Info
The biggest wins with this flag is the possibility to use
dotenv
andesm
packages. Unfortunately,esm
does nothing becausecosmiconfig
usesrequire-from-string
(track progress here cosmiconfig/cosmiconfig#109).