Skip to content

Commit f67bff7

Browse files
jamestalmagebcoe
authored andcommitted
fix: avoid pid collisions. (#301)
With AVA's concurrency flag, it's possible that two processes during a test run will share the same pid. Avoid this collision by hashing the pid with process.hrtime for a truly unique value.
1 parent 48dbef6 commit f67bff7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,12 @@ NYC.prototype.writeCoverageFile = function () {
299299
coverage = this.sourceMapTransform(coverage)
300300
}
301301

302+
var id = md5hex(
303+
process.hrtime().concat(process.pid).map(String)
304+
)
305+
302306
fs.writeFileSync(
303-
path.resolve(this.tempDirectory(), './', process.pid + '.json'),
307+
path.resolve(this.tempDirectory(), './', id + '.json'),
304308
JSON.stringify(coverage),
305309
'utf-8'
306310
)

0 commit comments

Comments
 (0)