Last active
April 18, 2019 01:04
-
-
Save isaacs/98ccdfc9793c4008242108e80fae5ee0 to your computer and use it in GitHub Desktop.
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
var sw = require('spawn-wrap') | |
var NYC = require('../index.js') | |
var config = {} | |
if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG) | |
config.isChildProcess = true | |
config._processInfo = { | |
pid: process.pid, | |
ppid: process.ppid, | |
parent: process.env.NYC_PROCESS_ID || null, | |
root: process.env.NYC_ROOT_ID | |
} | |
if (process.env.NYC_PROCESSINFO_EXTERNAL_ID) { | |
config._processInfo.externalId = process.env.NYC_PROCESSINFO_EXTERNAL_ID | |
delete process.env.NYC_PROCESSINFO_EXTERNAL_ID | |
} | |
if (process.env.NYC_CONFIG_OVERRIDE) { | |
var override = JSON.parse(process.env.NYC_CONFIG_OVERRIDE) | |
config = Object.assign(config, override) | |
process.env.NYC_CONFIG = JSON.stringify(config) | |
} | |
;(new NYC(config)).wrap() | |
sw.runMain() |
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
diff --git a/bin/wrap.js b/bin/wrap.js | |
index 1cff275..4e64c2b 100644 | |
--- a/bin/wrap.js | |
+++ b/bin/wrap.js | |
@@ -16,6 +16,12 @@ if (process.env.NYC_PROCESSINFO_EXTERNAL_ID) { | |
delete process.env.NYC_PROCESSINFO_EXTERNAL_ID | |
} | |
+if (process.env.NYC_CONFIG_OVERRIDE) { | |
+ var override = JSON.parse(process.env.NYC_CONFIG_OVERRIDE) | |
+ config = Object.assign(config, override) | |
+ process.env.NYC_CONFIG = JSON.stringify(config) | |
+} | |
+ | |
;(new NYC(config)).wrap() | |
sw.runMain() |
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
const config = JSON.parse(process.env.NYC_CONFIG || /* istanbul ignore next */ '{}') | |
console.log('in dumper', {include: config.include}) |
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
#!/usr/local/bin/node ./bin/nyc.js --no-exclude-after-remap --include=dump-root.js node | |
const config = JSON.parse(process.env.NYC_CONFIG || /* istanbul ignore next */ '{}') | |
const {include,exclude} = config | |
const dumper = require.resolve('./dump-config.js') | |
if (process.argv[2] !== 'child') { | |
console.error('in parent', {include}) | |
require('child_process').spawn(process.execPath, [__filename, 'child'], { | |
env: { | |
...process.env, | |
NYC_CONFIG_OVERRIDE: JSON.stringify({ | |
include: 'dump-config.js', | |
}), | |
}, | |
stdio: 'inherit', | |
}) | |
} else { | |
// this should run, but not be covered, even though the shebang says to | |
// the child run ONLY covers the child file, not the dump-root.js | |
console.error('in child', {include}) | |
require(dumper) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output