Skip to content

Commit

Permalink
chore: Remove cp-file module (#1230)
Browse files Browse the repository at this point in the history
This slightly reduces the amount of code nyc loads by using the core
fs.copyFile function.  Clarify `package.json#engines` to show that
node.js 8.9.0 (LTS) is the oldest supported release.
  • Loading branch information
coreyfarrell authored Nov 19, 2019
1 parent dfd629d commit 7307626
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 44 deletions.
23 changes: 16 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/* global __coverage__ */

const cachingTransform = require('caching-transform')
const cpFile = require('cp-file')
const findCacheDir = require('find-cache-dir')
const fs = require('./lib/fs-promises')
const os = require('os')
Expand Down Expand Up @@ -225,13 +224,23 @@ class NYC {

const concurrency = output ? os.cpus().length : 1
if (this.config.completeCopy && output) {
const files = await glob(path.resolve(input, '**'), {
dot: true,
nodir: true,
ignore: ['**/.git', '**/.git/**', path.join(output, '**')]
})
const destDirs = new Set(
files.map(src => path.dirname(path.join(output, path.relative(input, src))))
)

await pMap(
destDirs,
dir => mkdirp(dir),
{ concurrency }
)
await pMap(
await glob(path.resolve(input, '**'), {
dot: true,
nodir: true,
ignore: ['**/.git', '**/.git/**', path.join(output, '**')]
}),
src => cpFile(src, path.join(output, path.relative(input, src))),
files,
src => fs.copyFile(src, path.join(output, path.relative(input, src))),
{ concurrency }
)
}
Expand Down
35 changes: 2 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@istanbuljs/schema": "^0.1.1",
"caching-transform": "^4.0.0",
"convert-source-map": "^1.7.0",
"cp-file": "^7.0.0",
"decamelize": "^1.2.0",
"find-cache-dir": "=3.0.0",
"find-up": "^4.1.0",
Expand Down Expand Up @@ -96,7 +95,7 @@
"which": "^2.0.1"
},
"engines": {
"node": ">=8"
"node": ">=8.9"
},
"homepage": "https://istanbul.js.org/",
"repository": {
Expand Down
3 changes: 1 addition & 2 deletions test/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { promisify } = require('util')

const t = require('tap')
const makeDir = require('make-dir')
const cpFile = require('cp-file')
const isWindows = require('is-windows')()
const rimraf = promisify(require('rimraf'))

Expand Down Expand Up @@ -243,7 +242,7 @@ t.test('can write files in place with --in-place switch', async t => {
const sourceDir = path.resolve(fixturesCLI, 'instrument-inplace')
await makeDir(outputDir)
await Promise.all(['package.json', 'file1.js', 'file2.js'].map(
file => cpFile(path.join(sourceDir, file), path.join(outputDir, file))
file => fs.copyFile(path.join(sourceDir, file), path.join(outputDir, file))
))

const { status } = await runNYC({
Expand Down

0 comments on commit 7307626

Please sign in to comment.