Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump foreground-child from ^2.0.0 to ^3.0.0 #1546

Merged
merged 10 commits into from
Sep 13, 2024
26 changes: 21 additions & 5 deletions bin/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

const configUtil = require('../lib/config-util')
const { cliWrapper, suppressEPIPE } = require('../lib/commands/helpers')
const foreground = require('foreground-child')
const { foregroundChild } = require('foreground-child')
const resolveFrom = require('resolve-from')
const NYC = require('../index.js')
const path = require('path')
const fs = require('fs')

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

try {
// clean up foreground-child watchdog process info
const parentDir = path.resolve(nyc.tempDirectory())
const dir = path.resolve(nyc.tempDirectory(), 'processinfo')
const files = await nyc.coverageFiles(dir)
for (let i = 0; i < files.length; i++) {
const data = await nyc.coverageFileLoad(files[i], dir)
if (data.pid === processInfo.watchdogPid) {
fs.unlinkSync(path.resolve(parentDir, files[i]))
fs.unlinkSync(path.resolve(dir, files[i]))
}
}

await nyc.writeProcessIndex()

nyc.maybePurgeSourceMapCache()
Expand All @@ -100,18 +114,20 @@ async function main () {
branches: argv.branches,
statements: argv.statements
}, argv['per-file']).catch(suppressEPIPE)
process.exitCode = process.exitCode || mainChildExitCode
exitCode = process.exitCode || exitCode
}

if (!argv.silent) {
await nyc.report().catch(suppressEPIPE)
}
} catch (error) {
/* istanbul ignore next */
process.exitCode = process.exitCode || mainChildExitCode || 1
exitCode = process.exitCode || exitCode || 1
/* istanbul ignore next */
console.error(error.message)
}

return exitCode
})
}

Expand Down
Loading