Skip to content

Commit af74d1e

Browse files
authored
feat(deps): bump foreground-child from ^2.0.0 to ^3.0.0 (#1546)
1 parent ae657b6 commit af74d1e

File tree

4 files changed

+69
-282
lines changed

4 files changed

+69
-282
lines changed

bin/nyc.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
const configUtil = require('../lib/config-util')
55
const { cliWrapper, suppressEPIPE } = require('../lib/commands/helpers')
6-
const foreground = require('foreground-child')
6+
const { foregroundChild } = require('foreground-child')
77
const resolveFrom = require('resolve-from')
88
const NYC = require('../index.js')
9+
const path = require('path')
10+
const fs = require('fs')
911

1012
// parse configuration and command-line arguments;
1113
// we keep these values in a few different forms,
@@ -86,10 +88,22 @@ async function main () {
8688
// set process.exitCode. Keep track so that both children are run, but
8789
// a non-zero exit codes in either one leads to an overall non-zero exit code.
8890
process.exitCode = 0
89-
foreground(childArgs, async () => {
90-
const mainChildExitCode = process.exitCode
91+
foregroundChild(childArgs, async (code, signal, processInfo) => {
92+
let exitCode = process.exitCode || code
9193

9294
try {
95+
// clean up foreground-child watchdog process info
96+
const parentDir = path.resolve(nyc.tempDirectory())
97+
const dir = path.resolve(nyc.tempDirectory(), 'processinfo')
98+
const files = await nyc.coverageFiles(dir)
99+
for (let i = 0; i < files.length; i++) {
100+
const data = await nyc.coverageFileLoad(files[i], dir)
101+
if (data.pid === processInfo.watchdogPid) {
102+
fs.unlinkSync(path.resolve(parentDir, files[i]))
103+
fs.unlinkSync(path.resolve(dir, files[i]))
104+
}
105+
}
106+
93107
await nyc.writeProcessIndex()
94108

95109
nyc.maybePurgeSourceMapCache()
@@ -100,18 +114,20 @@ async function main () {
100114
branches: argv.branches,
101115
statements: argv.statements
102116
}, argv['per-file']).catch(suppressEPIPE)
103-
process.exitCode = process.exitCode || mainChildExitCode
117+
exitCode = process.exitCode || exitCode
104118
}
105119

106120
if (!argv.silent) {
107121
await nyc.report().catch(suppressEPIPE)
108122
}
109123
} catch (error) {
110124
/* istanbul ignore next */
111-
process.exitCode = process.exitCode || mainChildExitCode || 1
125+
exitCode = process.exitCode || exitCode || 1
112126
/* istanbul ignore next */
113127
console.error(error.message)
114128
}
129+
130+
return exitCode
115131
})
116132
}
117133

0 commit comments

Comments
 (0)