-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
feat: adds instrument command line option #298
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,55 @@ | ||
var NYC | ||
try { | ||
NYC = require('../../index.covered.js') | ||
} catch (e) { | ||
NYC = require('../../index.js') | ||
} | ||
|
||
exports.command = 'instrument <input> [output]' | ||
|
||
exports.describe = 'instruments a file or a directory tree and writes the instrumented code to the desired output location' | ||
|
||
exports.builder = function (yargs) { | ||
return yargs | ||
.usage('$0 instrument <input> [output]') | ||
.option('require', { | ||
alias: 'i', | ||
default: [], | ||
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.' | ||
}) | ||
.option('extension', { | ||
alias: 'e', | ||
default: [], | ||
describe: 'a list of extensions that nyc should handle in addition to .js' | ||
}) | ||
.option('source-map', { | ||
default: true, | ||
type: 'boolean', | ||
description: 'should nyc detect and handle source maps?' | ||
}) | ||
.option('instrument', { | ||
default: true, | ||
type: 'boolean', | ||
description: 'should nyc handle instrumentation?' | ||
}) | ||
.example('$0 instrument ./lib ./output', 'instrument all .js files in ./lib with coverage and output in ./output') | ||
} | ||
|
||
exports.handler = function (argv) { | ||
// if instrument is set to false, | ||
// enable a noop instrumenter. | ||
if (!argv.instrument) argv.instrumenter = './lib/instrumenters/noop' | ||
else argv.instrumenter = './lib/instrumenters/istanbul' | ||
|
||
var nyc = new NYC({ | ||
instrumenter: argv.instrumenter, | ||
sourceMap: argv.sourceMap, | ||
extension: argv.extension, | ||
require: argv.require | ||
}) | ||
|
||
nyc.instrumentAllFiles(argv.input, argv.output, function (err) { | ||
if (err) console.error(err.message) | ||
process.exit(1) | ||
}) | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Interesting. Is there a reason this is
90
instead of0
?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.
just picking defaults based on personal preference, I tend to find a project with
90%+
test coverage is pretty healthy.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.
I see. Maybe I'm misunderstanding what these numbers mean, but shouldn't that be true of the other thresholds as well?
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.
I think you're right, just not as experienced with the other thresholds.
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.
Yeah, me either. I only think that I sort of understand what they really mean, but I'm not certain...