UNPKG

1.4 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3var optimist = require('optimist');
4var jscov = require('../lib/jscov');
5
6var argv = optimist
7 .usage("jscov is a tool that measures code coverage for JavaScript programs.\n\njscov is modelled after JSCoverage (http://siliconforks.com/jscoverage),\nbut implemented in pure JavaScript and can be used as a direct replacement.\n\nUsage: jscov sourcedir targetdir")
8 .boolean('expand')
9 .boolean('conditionals')
10 .boolean('hidden')
11 .boolean('verbose')
12 .describe('version', 'Print the current version number')
13 .describe('help', 'Show this help message')
14 .describe('expand', 'Expands lazy operators and if-statements to give higher resolution coverage data')
15 .describe('hidden', 'Covers hidden files')
16 .describe('verbose', 'Prints additional information during coverage')
17 .describe('conditionals', 'Expands conditional JSCOV-comments to test additional execution paths')
18 .alias('version', 'v')
19 .alias('help', 'h')
20 .argv;
21
22if (argv.help) {
23 console.log(optimist.help());
24 return;
25}
26
27if (argv.version) {
28 console.log(require('../package.json').version);
29 return;
30}
31
32if (argv._.length != 2) {
33 optimist.showHelp();
34 return;
35}
36
37jscov.rewriteFolder(argv._[0], argv._[1], {
38 expand: argv.expand,
39 hidden: argv.hidden,
40 verbose: argv.verbose,
41 conditionals: argv.conditionals
42}, function(err) {
43 if (err) {
44 console.log(err);
45 process.exit(1);
46 }
47});