diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:38:50 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-28 00:40:43 +0200 |
commit | 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch) | |
tree | 6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/nyc/lib/commands/instrument.js | |
parent | 963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff) |
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/nyc/lib/commands/instrument.js')
-rw-r--r-- | node_modules/nyc/lib/commands/instrument.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/nyc/lib/commands/instrument.js b/node_modules/nyc/lib/commands/instrument.js new file mode 100644 index 000000000..6ff4a5222 --- /dev/null +++ b/node_modules/nyc/lib/commands/instrument.js @@ -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) + }) +} |