diff --git a/bin/wrap.js b/bin/wrap.js index b4c916156..cc01d23a7 100644 --- a/bin/wrap.js +++ b/bin/wrap.js @@ -1,15 +1,13 @@ var sw = require('spawn-wrap') var NYC = require('../index.js') -var parentPid = process.env.NYC_PARENT_PID || '0' -process.env.NYC_PARENT_PID = process.pid - var config = {} if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG) config.isChildProcess = true config._processInfo = { - ppid: parentPid, + pid: process.pid, + ppid: process.ppid, root: process.env.NYC_ROOT_ID } diff --git a/test/nyc-integration.js b/test/nyc-integration.js index 999e5102b..53527ffd8 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -1127,7 +1127,13 @@ describe('the nyc cli', function () { proc.on('close', function (code) { code.should.equal(0) stdout.should.not.match(new RegExp('└─')) - fs.statSync(path.resolve(fixturesCLI, '.nyc_output', 'processinfo')) + const dir = path.resolve(fixturesCLI, '.nyc_output', 'processinfo') + fs.statSync(dir) + // make sure that the processinfo file has a numeric pid and ppid + const files = fs.readdirSync(dir).filter(f => f !== 'index.json') + const data = JSON.parse(fs.readFileSync(dir + '/' + files[0], 'utf8')) + data.pid.should.be.a('number') + data.ppid.should.be.a('number') done() }) })