Skip to content

Commit 32f75b0

Browse files
isaacscoreyfarrell
authored andcommitted
fix: set processinfo pid/ppid to actual numbers (#1057)
As of Node.js v6, process.ppid is available, and a number. So, there's no need to pass the parent PID through the environment, which casts it to a string. BREAKING CHANGE: this changes the data type of the pid/ppid fields in processinfo files
1 parent 16d4315 commit 32f75b0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

bin/wrap.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
var sw = require('spawn-wrap')
22
var NYC = require('../index.js')
33

4-
var parentPid = process.env.NYC_PARENT_PID || '0'
5-
process.env.NYC_PARENT_PID = process.pid
6-
74
var config = {}
85
if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG)
96
config.isChildProcess = true
107

118
config._processInfo = {
12-
ppid: parentPid,
9+
pid: process.pid,
10+
ppid: process.ppid,
1311
root: process.env.NYC_ROOT_ID
1412
}
1513

test/nyc-integration.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,13 @@ describe('the nyc cli', function () {
11271127
proc.on('close', function (code) {
11281128
code.should.equal(0)
11291129
stdout.should.not.match(new RegExp('└─'))
1130-
fs.statSync(path.resolve(fixturesCLI, '.nyc_output', 'processinfo'))
1130+
const dir = path.resolve(fixturesCLI, '.nyc_output', 'processinfo')
1131+
fs.statSync(dir)
1132+
// make sure that the processinfo file has a numeric pid and ppid
1133+
const files = fs.readdirSync(dir).filter(f => f !== 'index.json')
1134+
const data = JSON.parse(fs.readFileSync(dir + '/' + files[0], 'utf8'))
1135+
data.pid.should.be.a('number')
1136+
data.ppid.should.be.a('number')
11311137
done()
11321138
})
11331139
})

0 commit comments

Comments
 (0)