From 40b19972889d5333f98436db9dd9c87d5c5fcbd6 Mon Sep 17 00:00:00 2001 From: Nathan Walters Date: Mon, 29 Jan 2024 15:35:09 -0800 Subject: [PATCH 1/8] chore(deps): bump foreground-child from ^2.0.0 to ^3.0.0 --- bin/nyc.js | 4 ++-- package.json | 2 +- test/fixtures/cli/fakebin/npm-template.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/nyc.js b/bin/nyc.js index e6a9be883..86410e40f 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -3,7 +3,7 @@ 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') @@ -86,7 +86,7 @@ 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 () => { + foregroundChild(childArgs, async () => { const mainChildExitCode = process.exitCode try { diff --git a/package.json b/package.json index 94fe276be..bd6131981 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "decamelize": "^1.2.0", "find-cache-dir": "^3.2.0", "find-up": "^4.1.0", - "foreground-child": "^2.0.0", + "foreground-child": "^3.0.0", "get-package-type": "^0.1.0", "glob": "^7.1.6", "istanbul-lib-coverage": "^3.0.0", diff --git a/test/fixtures/cli/fakebin/npm-template.js b/test/fixtures/cli/fakebin/npm-template.js index b947795f6..072da38a9 100644 --- a/test/fixtures/cli/fakebin/npm-template.js +++ b/test/fixtures/cli/fakebin/npm-template.js @@ -1,9 +1,9 @@ // shebang gets added before this line var which = require('which') var assert = require('assert') -var foreground = require('foreground-child') +var { foregroundChild } = require('foreground-child') // strip first PATH folder process.env.PATH = process.env.PATH.replace(/^.+?[:;]/, '') -foreground('npm', process.argv.slice(2)) +foregroundChild('npm', process.argv.slice(2)) From 825bdbcf11b3f1145497db402f4418599c362673 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Fri, 19 Apr 2024 09:48:02 -0700 Subject: [PATCH 2/8] Update package-lock.json --- package-lock.json | 319 +++++++--------------------------------------- 1 file changed, 45 insertions(+), 274 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64aaef634..17f086e71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "decamelize": "^1.2.0", "find-cache-dir": "^3.2.0", "find-up": "^4.1.0", - "foreground-child": "^2.0.0", + "foreground-child": "^3.0.0", "get-package-type": "^0.1.0", "glob": "^7.1.6", "istanbul-lib-coverage": "^3.0.0", @@ -821,22 +821,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@npmcli/package-json/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@npmcli/package-json/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -937,18 +921,6 @@ "node": ">=10" } }, - "node_modules/@npmcli/package-json/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@npmcli/package-json/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -1333,22 +1305,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@tapjs/fixture/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tapjs/fixture/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -1419,18 +1375,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@tapjs/fixture/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tapjs/intercept": { "version": "1.2.20", "resolved": "https://registry.npmjs.org/@tapjs/intercept/-/intercept-1.2.20.tgz", @@ -1639,22 +1583,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@tapjs/run/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tapjs/run/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -1901,22 +1829,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/@tapjs/test/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tapjs/test/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -1987,18 +1899,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/@tapjs/test/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@tapjs/typescript": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/@tapjs/typescript/-/typescript-1.4.2.tgz", @@ -2638,6 +2538,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/c8/node_modules/foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/c8/node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -2780,22 +2693,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/cacache/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/cacache/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -2857,18 +2754,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cacache/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/caching-transform": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", @@ -5026,15 +4911,29 @@ } }, "node_modules/foreground-child": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", - "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", "dependencies": { "cross-spawn": "^7.0.0", - "signal-exit": "^3.0.2" + "signal-exit": "^4.0.1" }, "engines": { - "node": ">=8.0.0" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/fromentries": { @@ -7602,22 +7501,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/node-gyp/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/node-gyp/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -7691,18 +7574,6 @@ "node": ">=10" } }, - "node_modules/node-gyp/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/node-gyp/node_modules/which": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", @@ -8803,22 +8674,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/read-package-json/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/read-package-json/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -8919,18 +8774,6 @@ "node": ">=10" } }, - "node_modules/read-package-json/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/read-package-json/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -9184,22 +9027,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/resolve-import/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/resolve-import/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -9237,18 +9064,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/resolve-import/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -9598,6 +9413,18 @@ "node": ">=8" } }, + "node_modules/spawn-wrap/node_modules/foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/spdx-correct": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", @@ -10252,22 +10079,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/sync-content/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/sync-content/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -10338,18 +10149,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/sync-content/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/table": { "version": "5.4.6", "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", @@ -10678,22 +10477,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/tshy/node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/tshy/node_modules/glob": { "version": "10.3.12", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.12.tgz", @@ -10764,18 +10547,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/tshy/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", From 62735fedb6f3241209b628f0747f0cbd95c71a7a Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Fri, 19 Apr 2024 12:53:58 -0700 Subject: [PATCH 3/8] Set exitCode correctly --- bin/nyc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/nyc.js b/bin/nyc.js index 86410e40f..e424da9e9 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -87,7 +87,7 @@ async function main () { // a non-zero exit codes in either one leads to an overall non-zero exit code. process.exitCode = 0 foregroundChild(childArgs, async () => { - const mainChildExitCode = process.exitCode + let exitCode = process.exitCode try { await nyc.writeProcessIndex() @@ -100,7 +100,7 @@ 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) { @@ -108,10 +108,12 @@ async function main () { } } 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 }) } From 82b79423446bc08801d53103252d9a91e615e805 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Thu, 9 May 2024 17:17:39 -0700 Subject: [PATCH 4/8] Fix as many tests as possible --- bin/nyc.js | 4 ++-- test/nyc-integration.js | 6 +++--- test/processinfo.js | 2 ++ test/temp-dir.js | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/nyc.js b/bin/nyc.js index e424da9e9..8e5cdd13a 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -86,8 +86,8 @@ 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 - foregroundChild(childArgs, async () => { - let exitCode = process.exitCode + foregroundChild(childArgs, async (code) => { + let exitCode = process.exitCode || code try { await nyc.writeProcessIndex() diff --git a/test/nyc-integration.js b/test/nyc-integration.js index e510b2d95..bf6db7f0c 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -193,9 +193,9 @@ t.test('interprets first args after -- as Node.js execArgv', t => testSuccess(t, args: ['--', '--expose-gc', path.resolve(fixturesCLI, 'gc.js')] })) -t.test('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { - args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] -})) +// t.test('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { +// args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] +// })) t.test('--use-spawn-wrap=true is functional', t => testSuccess(t, { args: ['--use-spawn-wrap=true', process.execPath, 'selfspawn-fibonacci.js', '5'] diff --git a/test/processinfo.js b/test/processinfo.js index 30290234e..480d7c180 100644 --- a/test/processinfo.js +++ b/test/processinfo.js @@ -32,6 +32,8 @@ t.test('build some processinfo', t => { proc.stderr.resume() proc.stdout.resume() proc.on('close', (code, signal) => { + // The subprocess is failing with the following error: + // " External ID blorp used by multiple processes" t.equal(code, 0) t.equal(signal, null) t.end() diff --git a/test/temp-dir.js b/test/temp-dir.js index 70d28654e..22944ae63 100644 --- a/test/temp-dir.js +++ b/test/temp-dir.js @@ -33,7 +33,7 @@ t.test('creates the default \'tempDir\' when none is specified', async t => { t.equal(cliFiles.includes('.temp_directory'), false) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.nyc_output')) - t.equal(tempFiles.length, 2) // the coverage file, and processinfo + t.equal(tempFiles.length, 3) // two coverage files, and processinfo }) t.test('prefers \'tempDirectory\' to \'tempDir\'', async t => { @@ -56,7 +56,7 @@ t.test('prefers \'tempDirectory\' to \'tempDir\'', async t => { t.equal(cliFiles.includes('.temp_directory'), true) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.temp_directory')) - t.equal(tempFiles.length, 2) + t.equal(tempFiles.length, 3) }) t.test('uses the \'tempDir\' option if \'tempDirectory\' is not set', async t => { @@ -77,5 +77,5 @@ t.test('uses the \'tempDir\' option if \'tempDirectory\' is not set', async t => t.equal(cliFiles.includes('.temp_directory'), false) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.temp_dir')) - t.equal(tempFiles.length, 2) + t.equal(tempFiles.length, 3) }) From b331787d5e9642a4cabe4b363ec5bb4efb328c89 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Thu, 9 May 2024 17:20:36 -0700 Subject: [PATCH 5/8] Add comment with link to PR --- test/nyc-integration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/nyc-integration.js b/test/nyc-integration.js index bf6db7f0c..35d0b9eab 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -193,6 +193,7 @@ t.test('interprets first args after -- as Node.js execArgv', t => testSuccess(t, args: ['--', '--expose-gc', path.resolve(fixturesCLI, 'gc.js')] })) +// Disabled; see https://github.com/istanbuljs/nyc/pull/1546 // t.test('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { // args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] // })) From c87fa50713a4db282ff26dc1921e0abd1a30b7c1 Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Thu, 16 May 2024 11:58:11 -0700 Subject: [PATCH 6/8] Skip all failing tests --- test/nyc-integration.js | 9 +++++---- test/processinfo.js | 15 ++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/nyc-integration.js b/test/nyc-integration.js index 35d0b9eab..54f7be666 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -193,10 +193,11 @@ t.test('interprets first args after -- as Node.js execArgv', t => testSuccess(t, args: ['--', '--expose-gc', path.resolve(fixturesCLI, 'gc.js')] })) -// Disabled; see https://github.com/istanbuljs/nyc/pull/1546 -// t.test('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { -// args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] -// })) +// TODO; get this test to pass with `foreground-child@^3.0.0` or delete. +// See https://github.com/istanbuljs/nyc/pull/1546 +t.skip('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { + args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] +})) t.test('--use-spawn-wrap=true is functional', t => testSuccess(t, { args: ['--use-spawn-wrap=true', process.execPath, 'selfspawn-fibonacci.js', '5'] diff --git a/test/processinfo.js b/test/processinfo.js index 480d7c180..71840ec28 100644 --- a/test/processinfo.js +++ b/test/processinfo.js @@ -16,7 +16,12 @@ const resolvedJS = resolve(fixturesCLI, 'selfspawn-fibonacci.js') rimraf.sync(resolve(fixturesCLI, tmp)) t.teardown(() => rimraf(resolve(fixturesCLI, tmp))) -t.test('build some processinfo', t => { +// TODO; get this test to pass with `foreground-child@^3.0.0` or delete. +// See https://github.com/istanbuljs/nyc/pull/1546 +// +// The subprocess is failing with the following error: +// " External ID blorp used by multiple processes" +t.skip('build some processinfo', t => { var args = [ bin, '-t', tmp, node, 'selfspawn-fibonacci.js', '5' @@ -32,15 +37,14 @@ t.test('build some processinfo', t => { proc.stderr.resume() proc.stdout.resume() proc.on('close', (code, signal) => { - // The subprocess is failing with the following error: - // " External ID blorp used by multiple processes" t.equal(code, 0) t.equal(signal, null) t.end() }) }) -t.test('validate the created processinfo data', async t => { +// This test is skipped because it relies on the above "build some processinfo" test. +t.skip('validate the created processinfo data', async t => { const covs = (await fs.readdir(resolve(fixturesCLI, tmp))) .filter(f => f !== 'processinfo') @@ -69,7 +73,8 @@ t.test('validate the created processinfo data', async t => { })) }) -t.test('check out the index', async t => { +// This test is skipped because it relies on the above "build some processinfo" test. +t.skip('check out the index', async t => { const indexFile = resolve(fixturesCLI, tmp, 'processinfo', 'index.json') const indexJson = await fs.readFile(indexFile, 'utf-8') const index = JSON.parse(indexJson) From e4e46130e45fd0bcf555580757e2ca11a5ae370a Mon Sep 17 00:00:00 2001 From: Anton Frattaroli Date: Fri, 30 Aug 2024 10:08:23 -0400 Subject: [PATCH 7/8] clean up additional files generated due to foreground-child watchdog (#1) --- bin/nyc.js | 16 +++++++++++++++- package-lock.json | 8 ++++---- package.json | 2 +- test/nyc-integration.js | 4 +--- test/processinfo.js | 13 +++---------- test/temp-dir.js | 6 +++--- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/bin/nyc.js b/bin/nyc.js index 8e5cdd13a..b2d5380bf 100755 --- a/bin/nyc.js +++ b/bin/nyc.js @@ -6,6 +6,8 @@ const { cliWrapper, suppressEPIPE } = require('../lib/commands/helpers') 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, @@ -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 - foregroundChild(childArgs, async (code) => { + 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() diff --git a/package-lock.json b/package-lock.json index 17f086e71..2f300cd4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "decamelize": "^1.2.0", "find-cache-dir": "^3.2.0", "find-up": "^4.1.0", - "foreground-child": "^3.0.0", + "foreground-child": "^3.3.0", "get-package-type": "^0.1.0", "glob": "^7.1.6", "istanbul-lib-coverage": "^3.0.0", @@ -4911,9 +4911,9 @@ } }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" diff --git a/package.json b/package.json index 7240c384d..5224fcb97 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "decamelize": "^1.2.0", "find-cache-dir": "^3.2.0", "find-up": "^4.1.0", - "foreground-child": "^3.0.0", + "foreground-child": "^3.3.0", "get-package-type": "^0.1.0", "glob": "^7.1.6", "istanbul-lib-coverage": "^3.0.0", diff --git a/test/nyc-integration.js b/test/nyc-integration.js index 54f7be666..e510b2d95 100644 --- a/test/nyc-integration.js +++ b/test/nyc-integration.js @@ -193,9 +193,7 @@ t.test('interprets first args after -- as Node.js execArgv', t => testSuccess(t, args: ['--', '--expose-gc', path.resolve(fixturesCLI, 'gc.js')] })) -// TODO; get this test to pass with `foreground-child@^3.0.0` or delete. -// See https://github.com/istanbuljs/nyc/pull/1546 -t.skip('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { +t.test('--show-process-tree displays a tree of spawned processes', t => testSuccess(t, { args: ['--show-process-tree', process.execPath, 'selfspawn-fibonacci.js', '5'] })) diff --git a/test/processinfo.js b/test/processinfo.js index 71840ec28..30290234e 100644 --- a/test/processinfo.js +++ b/test/processinfo.js @@ -16,12 +16,7 @@ const resolvedJS = resolve(fixturesCLI, 'selfspawn-fibonacci.js') rimraf.sync(resolve(fixturesCLI, tmp)) t.teardown(() => rimraf(resolve(fixturesCLI, tmp))) -// TODO; get this test to pass with `foreground-child@^3.0.0` or delete. -// See https://github.com/istanbuljs/nyc/pull/1546 -// -// The subprocess is failing with the following error: -// " External ID blorp used by multiple processes" -t.skip('build some processinfo', t => { +t.test('build some processinfo', t => { var args = [ bin, '-t', tmp, node, 'selfspawn-fibonacci.js', '5' @@ -43,8 +38,7 @@ t.skip('build some processinfo', t => { }) }) -// This test is skipped because it relies on the above "build some processinfo" test. -t.skip('validate the created processinfo data', async t => { +t.test('validate the created processinfo data', async t => { const covs = (await fs.readdir(resolve(fixturesCLI, tmp))) .filter(f => f !== 'processinfo') @@ -73,8 +67,7 @@ t.skip('validate the created processinfo data', async t => { })) }) -// This test is skipped because it relies on the above "build some processinfo" test. -t.skip('check out the index', async t => { +t.test('check out the index', async t => { const indexFile = resolve(fixturesCLI, tmp, 'processinfo', 'index.json') const indexJson = await fs.readFile(indexFile, 'utf-8') const index = JSON.parse(indexJson) diff --git a/test/temp-dir.js b/test/temp-dir.js index 22944ae63..dc550a9cd 100644 --- a/test/temp-dir.js +++ b/test/temp-dir.js @@ -33,7 +33,7 @@ t.test('creates the default \'tempDir\' when none is specified', async t => { t.equal(cliFiles.includes('.temp_directory'), false) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.nyc_output')) - t.equal(tempFiles.length, 3) // two coverage files, and processinfo + t.equal(tempFiles.length, 2) // a coverage file, and processinfo }) t.test('prefers \'tempDirectory\' to \'tempDir\'', async t => { @@ -56,7 +56,7 @@ t.test('prefers \'tempDirectory\' to \'tempDir\'', async t => { t.equal(cliFiles.includes('.temp_directory'), true) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.temp_directory')) - t.equal(tempFiles.length, 3) + t.equal(tempFiles.length, 2) }) t.test('uses the \'tempDir\' option if \'tempDirectory\' is not set', async t => { @@ -77,5 +77,5 @@ t.test('uses the \'tempDir\' option if \'tempDirectory\' is not set', async t => t.equal(cliFiles.includes('.temp_directory'), false) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.temp_dir')) - t.equal(tempFiles.length, 3) + t.equal(tempFiles.length, 2) }) From fba1f798e982342da592dda7980bba8c967c552b Mon Sep 17 00:00:00 2001 From: Nathan Sarang-Walters Date: Fri, 30 Aug 2024 07:10:08 -0700 Subject: [PATCH 8/8] Update test/temp-dir.js --- test/temp-dir.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/temp-dir.js b/test/temp-dir.js index dc550a9cd..70d28654e 100644 --- a/test/temp-dir.js +++ b/test/temp-dir.js @@ -33,7 +33,7 @@ t.test('creates the default \'tempDir\' when none is specified', async t => { t.equal(cliFiles.includes('.temp_directory'), false) const tempFiles = await fs.readdir(path.resolve(fixturesCLI, '.nyc_output')) - t.equal(tempFiles.length, 2) // a coverage file, and processinfo + t.equal(tempFiles.length, 2) // the coverage file, and processinfo }) t.test('prefers \'tempDirectory\' to \'tempDir\'', async t => {