-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print warning message for --opts
argument
#3352
Changes from all commits
a348107
8b200d3
2dbc42f
35508b2
f5cd0b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,18 @@ function getOptions() { | |
return; | ||
} | ||
|
||
const optsPath = | ||
process.argv.indexOf('--opts') === -1 | ||
? 'test/mocha.opts' | ||
: process.argv[process.argv.indexOf('--opts') + 1]; | ||
const optPathSpecified = process.argv.indexOf('--opts') > -1; | ||
const optsPath = optPathSpecified | ||
? process.argv[process.argv.indexOf('--opts') + 1] | ||
: 'test/mocha.opts'; | ||
|
||
if (optPathSpecified && !fs.existsSync(optsPath)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to just do it and recover instead of make this extra check. So on L52 where we're catching the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (in other words, avoid |
||
const noSuchFileError = new Error( | ||
`Specified options file does not exist: ${optsPath}` | ||
); | ||
noSuchFileError.code = 'ENOENT'; | ||
throw noSuchFileError; | ||
} | ||
|
||
try { | ||
const opts = fs | ||
|
@@ -44,5 +52,5 @@ function getOptions() { | |
// ignore | ||
} | ||
|
||
process.env.LOADED_MOCHA_OPTS = true; | ||
process.env.LOADED_MOCHA_OPTS = 'true'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK, so, to be clear, this is good enough the way it is. It should be Projects should not be depending on this variable, and should certainly not be depending on its value to be any particular thing other than set or unset. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value needs to be 'true' to prevent breaking other npm packages unnecessarily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What packages are using this? This is not documented and is not a "public" API (or an API at all, really). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @boneskull. |
||
} |
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 is nitpicky but can you please save the index? DRY and all that