Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function main () {
if (!argv.instrument) argv.instrumenter = './lib/instrumenters/noop'
else argv.instrumenter = './lib/instrumenters/istanbul'

var nyc = (new NYC(argv))
const nyc = (new NYC(argv))
if (argv.clean) {
await nyc.reset()
} else {
Expand Down
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const libHook = require('istanbul-lib-hook')
const { ProcessInfo, ProcessDB } = require('istanbul-lib-processinfo')
const mkdirp = require('make-dir')
const Module = require('module')
const onExit = require('signal-exit')
const { onExit } = require('signal-exit')
const path = require('path')
const rimraf = promisify(require('rimraf'))
const { rimraf } = require('rimraf')
const SourceMaps = require('./lib/source-maps')
const TestExclude = require('test-exclude')
const pMap = require('p-map')
Expand All @@ -32,7 +32,7 @@ const selfCoverageHelper = global[nycSelfCoverageHelper] || {
}

function coverageFinder () {
var coverage = global.__coverage__
let coverage = global.__coverage__
if (typeof __coverage__ === 'object') coverage = __coverage__
if (!coverage) coverage = global.__coverage__ = {}
return coverage
Expand Down Expand Up @@ -105,7 +105,7 @@ class NYC {
// when running --all we should not load source-file from
// cache, we want to instead return the fake source.
disableCache: this._disableCachingTransform(),
ext: ext
ext
}
if (this._eagerInstantiation) {
opts.transform = this._transformFactory(this.cacheDirectory)
Expand Down Expand Up @@ -153,8 +153,8 @@ class NYC {
}

_readTranspiledSource (filePath) {
var source = null
var ext = path.extname(filePath)
let source = null
let ext = path.extname(filePath)
if (typeof Module._extensions[ext] === 'undefined') {
ext = '.js'
}
Expand Down Expand Up @@ -386,7 +386,7 @@ class NYC {
}

writeCoverageFile () {
var coverage = coverageFinder()
const coverage = coverageFinder()

// Remove any files that should be excluded but snuck into the coverage
Object.keys(coverage).forEach(function (absFile) {
Expand All @@ -403,8 +403,8 @@ class NYC {
}, this)
}

var id = this.processInfo.uuid
var coverageFilename = path.resolve(this.tempDirectory(), id + '.json')
const id = this.processInfo.uuid
const coverageFilename = path.resolve(this.tempDirectory(), id + '.json')

fs.writeFileSync(
coverageFilename,
Expand Down Expand Up @@ -493,7 +493,7 @@ class NYC {

_checkCoverage (summary, thresholds, file) {
Object.keys(thresholds).forEach(function (key) {
var coverage = summary[key].pct
const coverage = summary[key].pct
if (coverage < thresholds[key]) {
process.exitCode = 1
if (file) {
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

const NYC = require('../../index.js')
const path = require('path')
const { promisify } = require('util')
const resolveFrom = require('resolve-from')
const rimraf = promisify(require('rimraf'))
const { rimraf } = require('rimraf')
const { cliWrapper, setupOptions } = require('./helpers.js')

exports.command = 'instrument <input> [output]'
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.builder = function (yargs) {

exports.handler = cliWrapper(async argv => {
process.env.NYC_CWD = process.cwd()
var nyc = new NYC(argv)
const nyc = new NYC(argv)
await nyc.report().catch(suppressEPIPE)
if (argv.checkCoverage) {
await nyc.checkCoverage({
Expand Down
2 changes: 1 addition & 1 deletion lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function processConfig (cwd) {
.example('$0 npm test', 'instrument your tests with coverage')
.example('$0 --require @babel/register npm test', 'instrument your tests with coverage and transpile with Babel')
.example('$0 report --reporter=text-lcov', 'output lcov report after running your tests')
.epilog('visit https://git.io/vHysA for list of available reporters')
.epilog('visit https://github.com/istanbuljs/istanbuljs/tree/main/packages/istanbul-reports/lib for list of available reporters')
.boolean('h')
.boolean('version')
.help(false)
Expand Down
4 changes: 2 additions & 2 deletions lib/instrumenters/istanbul.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ function InstrumenterIstanbul (options) {

return {
instrumentSync (code, filename, { sourceMap, registerMap }) {
var instrumented = instrumenter.instrumentSync(code, filename, sourceMap)
let instrumented = instrumenter.instrumentSync(code, filename, sourceMap)
if (instrumented !== code) {
registerMap()
}

// the instrumenter can optionally produce source maps,
// this is useful for features like remapping stack-traces.
if (options.produceSourceMap) {
var lastSourceMap = instrumenter.lastSourceMap()
const lastSourceMap = instrumenter.lastSourceMap()
/* istanbul ignore else */
if (lastSourceMap) {
instrumented += '\n' + convertSourceMap.fromObject(lastSourceMap).toComment()
Expand Down
8 changes: 4 additions & 4 deletions lib/process-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
// don't pass arguments that are meant
// for nyc to the bin being instrumented.
hideInstrumenterArgs: function (yargv) {
var argv = process.argv.slice(1)
let argv = process.argv.slice(1)
argv = argv.slice(argv.indexOf(yargv._[0]))
if (argv[0][0] === '-') {
argv.unshift(process.execPath)
Expand All @@ -22,10 +22,10 @@ module.exports = {
// don't pass arguments for the bin being
// instrumented to nyc.
hideInstrumenteeArgs: function () {
var argv = process.argv.slice(2)
var yargv = Parser(argv)
let argv = process.argv.slice(2)
const yargv = Parser(argv)
if (!yargv._.length) return argv
for (var i = 0, command; (command = yargv._[i]) !== undefined; i++) {
for (let i = 0, command; (command = yargv._[i]) !== undefined; i++) {
if (~commands.indexOf(command)) return argv
}

Expand Down
5 changes: 2 additions & 3 deletions npm-run-clean.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node
'use strict'

const { promisify } = require('util')
const rimraf = promisify(require('rimraf'))
const { rimraf } = require('rimraf')

Promise.all([
'**/.nyc_output',
Expand All @@ -16,4 +15,4 @@ Promise.all([
'test/fixtures/cli/nyc-config-js/node_modules',
'test/temp-dir-*',
'self-coverage'
].map(f => rimraf(f, { cwd: __dirname })))
].map(f => rimraf(f, { cwd: __dirname, glob: true })))
Loading
Loading