nyc 17.0.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/nyc.js CHANGED
@@ -3,9 +3,11 @@
3
3
 
4
4
  const configUtil = require('../lib/config-util')
5
5
  const { cliWrapper, suppressEPIPE } = require('../lib/commands/helpers')
6
- const foreground = require('foreground-child')
6
+ const { foregroundChild } = require('foreground-child')
7
7
  const resolveFrom = require('resolve-from')
8
8
  const NYC = require('../index.js')
9
+ const path = require('path')
10
+ const fs = require('fs')
9
11
 
10
12
  // parse configuration and command-line arguments;
11
13
  // we keep these values in a few different forms,
@@ -86,10 +88,22 @@ async function main () {
86
88
  // set process.exitCode. Keep track so that both children are run, but
87
89
  // a non-zero exit codes in either one leads to an overall non-zero exit code.
88
90
  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
91
93
 
92
94
  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
+
93
107
  await nyc.writeProcessIndex()
94
108
 
95
109
  nyc.maybePurgeSourceMapCache()
@@ -100,7 +114,7 @@ async function main () {
100
114
  branches: argv.branches,
101
115
  statements: argv.statements
102
116
  }, argv['per-file']).catch(suppressEPIPE)
103
- process.exitCode = process.exitCode || mainChildExitCode
117
+ exitCode = process.exitCode || exitCode
104
118
  }
105
119
 
106
120
  if (!argv.silent) {
@@ -108,10 +122,12 @@ async function main () {
108
122
  }
109
123
  } catch (error) {
110
124
  /* istanbul ignore next */
111
- process.exitCode = process.exitCode || mainChildExitCode || 1
125
+ exitCode = process.exitCode || exitCode || 1
112
126
  /* istanbul ignore next */
113
127
  console.error(error.message)
114
128
  }
129
+
130
+ return exitCode
115
131
  })
116
132
  }
117
133
 
package/index.js CHANGED
@@ -6,8 +6,8 @@ const cachingTransform = require('caching-transform')
6
6
  const findCacheDir = require('find-cache-dir')
7
7
  const fs = require('./lib/fs-promises')
8
8
  const os = require('os')
9
- const { debuglog, promisify } = require('util')
10
- const glob = promisify(require('glob'))
9
+ const { debuglog } = require('util')
10
+ const { glob } = require('glob')
11
11
  const Hash = require('./lib/hash')
12
12
  const libCoverage = require('istanbul-lib-coverage')
13
13
  const libHook = require('istanbul-lib-hook')
@@ -16,7 +16,7 @@ const mkdirp = require('make-dir')
16
16
  const Module = require('module')
17
17
  const onExit = require('signal-exit')
18
18
  const path = require('path')
19
- const rimraf = promisify(require('rimraf'))
19
+ const { rimraf } = require('rimraf')
20
20
  const SourceMaps = require('./lib/source-maps')
21
21
  const TestExclude = require('test-exclude')
22
22
  const pMap = require('p-map')
@@ -240,10 +240,10 @@ class NYC {
240
240
 
241
241
  const concurrency = output ? os.cpus().length : 1
242
242
  if (this.config.completeCopy && output) {
243
- const files = await glob(path.resolve(input, '**'), {
243
+ const files = await glob(path.resolve(input, '**').split(path.sep).join('/'), {
244
244
  dot: true,
245
245
  nodir: true,
246
- ignore: ['**/.git', '**/.git/**', path.join(output, '**')]
246
+ ignore: ['**/.git', '**/.git/**', path.join(output, '**').split(path.sep).join('/')]
247
247
  })
248
248
  const destDirs = new Set(
249
249
  files.map(src => path.dirname(path.join(output, path.relative(input, src))))
@@ -2,9 +2,8 @@
2
2
 
3
3
  const NYC = require('../../index.js')
4
4
  const path = require('path')
5
- const { promisify } = require('util')
6
5
  const resolveFrom = require('resolve-from')
7
- const rimraf = promisify(require('rimraf'))
6
+ const { rimraf } = require('rimraf')
8
7
  const { cliWrapper, setupOptions } = require('./helpers.js')
9
8
 
10
9
  exports.command = 'instrument <input> [output]'
@@ -41,6 +41,6 @@ exports.handler = cliWrapper(async argv => {
41
41
  }
42
42
  await makeDir(path.dirname(argv.outputFile))
43
43
  const map = await nyc.getCoverageMapFromAllCoverageFiles(argv.inputDirectory)
44
- await fs.writeFile(argv.outputFile, JSON.stringify(map, null, 2), 'utf8')
44
+ await fs.writeFile(argv.outputFile, JSON.stringify(map), 'utf8')
45
45
  console.info(`coverage files in ${argv.inputDirectory} merged into ${argv.outputFile}`)
46
46
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nyc",
3
- "version": "17.0.0",
3
+ "version": "18.0.0",
4
4
  "description": "the Istanbul command line interface",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -64,13 +64,13 @@
64
64
  "decamelize": "^1.2.0",
65
65
  "find-cache-dir": "^3.2.0",
66
66
  "find-up": "^4.1.0",
67
- "foreground-child": "^2.0.0",
67
+ "foreground-child": "^3.3.0",
68
68
  "get-package-type": "^0.1.0",
69
- "glob": "^7.1.6",
69
+ "glob": "^13.0.6",
70
70
  "istanbul-lib-coverage": "^3.0.0",
71
71
  "istanbul-lib-hook": "^3.0.0",
72
72
  "istanbul-lib-instrument": "^6.0.2",
73
- "istanbul-lib-processinfo": "^2.0.2",
73
+ "istanbul-lib-processinfo": "^3.0.0",
74
74
  "istanbul-lib-report": "^3.0.0",
75
75
  "istanbul-lib-source-maps": "^4.0.0",
76
76
  "istanbul-reports": "^3.0.2",
@@ -79,10 +79,10 @@
79
79
  "p-map": "^3.0.0",
80
80
  "process-on-spawn": "^1.0.0",
81
81
  "resolve-from": "^5.0.0",
82
- "rimraf": "^3.0.0",
82
+ "rimraf": "^6.1.3",
83
83
  "signal-exit": "^3.0.2",
84
- "spawn-wrap": "^2.0.0",
85
- "test-exclude": "^6.0.0",
84
+ "spawn-wrap": "^3.0.0",
85
+ "test-exclude": "^8.0.0",
86
86
  "yargs": "^15.0.2"
87
87
  },
88
88
  "devDependencies": {
@@ -97,7 +97,7 @@
97
97
  "which": "^2.0.2"
98
98
  },
99
99
  "engines": {
100
- "node": ">=18"
100
+ "node": "20 || >=22"
101
101
  },
102
102
  "homepage": "https://istanbul.js.org/",
103
103
  "bugs": "https://github.com/istanbuljs/nyc/issues",