-
-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nyc no longer tries to run arguments passed to the instrumented…
… bin (#322)
- Loading branch information
Showing
8 changed files
with
286 additions
and
167 deletions.
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
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
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,33 @@ | ||
var parser = require('yargs-parser') | ||
var commands = [ | ||
'report', | ||
'check-coverage', | ||
'instrument' | ||
] | ||
|
||
module.exports = { | ||
// don't pass arguments that are meant | ||
// for nyc to the bin being instrumented. | ||
hideInstrumenterArgs: function (yargv) { | ||
var argv = process.argv.slice(1) | ||
argv = argv.slice(argv.indexOf(yargv._[0])) | ||
return argv | ||
}, | ||
// don't pass arguments for the bin being | ||
// instrumented to nyc. | ||
hideInstrumenteeArgs: function () { | ||
var argv = process.argv.slice(2) | ||
var yargv = parser(argv) | ||
if (!yargv._.length) return argv | ||
for (var i = 0, command; (command = yargv._[i]) !== undefined; i++) { | ||
if (~commands.indexOf(command)) return argv | ||
} | ||
|
||
// drop all the arguments after the bin being | ||
// instrumented by nyc. | ||
argv = argv.slice(0, argv.indexOf(yargv._[0])) | ||
argv.push(yargv._[0]) | ||
|
||
return argv | ||
} | ||
} |
Oops, something went wrong.