-
-
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.
Merge pull request #6 from bcoe/new-spawn-wrap
things are actually close to working now \o/
- Loading branch information
Showing
33 changed files
with
129 additions
and
1,051 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
nyc_output | ||
coverage | ||
node_modules |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,25 +1,37 @@ | ||
#!/usr/bin/env node | ||
var sw = require('spawn-wrap') | ||
|
||
var NYC = require('../'), | ||
yargs = require('yargs') | ||
.usage('$0 [file-to-instrument]') | ||
.example('$0 ./node_modules/.bin/mocha', 'run mocha test-suite and output JSON files with coverage information') | ||
if (process.env.NYC_CWD) { | ||
var NYC = require('../') | ||
;(new NYC()).wrap() | ||
|
||
;(new NYC()).wrap() | ||
// make sure we can run coverage on | ||
// our own index.js, I like turtles. | ||
var name = require.resolve('../') | ||
delete require.cache[name] | ||
|
||
// make it so we can run coverage on nyc itself. | ||
var name = require.resolve('../') | ||
delete require.cache[name] | ||
sw.runMain() | ||
} else { | ||
var NYC = require('../') | ||
|
||
// hide the fact that nyc.js was used to execute command. | ||
if (process.argv[1].match((/(nyc.js$)|(nyc$)/))) process.argv.splice(1, 1) | ||
;(new NYC()).cleanup() | ||
|
||
// execute main on whatever file was wrapped by nyc. | ||
// ./bin/nyc.js ./node_modules/.bin/mocha | ||
if (process.argv[1]) { | ||
delete require('module')._cache[process.argv[1]] | ||
process.argv[1] = require('path').resolve(process.argv[1]) | ||
require('module').runMain() | ||
} else { | ||
yargs.showHelp() | ||
sw([__filename], { | ||
NYC_CWD: process.cwd() | ||
}) | ||
|
||
// this spawn gets wrapped | ||
var child = require('child_process').spawn( | ||
process.argv[2], | ||
process.argv.slice(3), | ||
{ stdio: 'inherit' } | ||
) | ||
|
||
child.on('close', function (code, signal) { | ||
if (signal) { | ||
process.kill(process.pid, signal) | ||
} else { | ||
process.exit(code) | ||
} | ||
}) | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.