Skip to content

Commit

Permalink
feat(deps): bump foreground-child from ^2.0.0 to ^3.0.0 (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalters512 authored Sep 13, 2024
1 parent ae657b6 commit af74d1e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 282 deletions.
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

0 comments on commit af74d1e

Please sign in to comment.