Skip to content
Draft
Show file tree
Hide file tree
Changes from 17 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 docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"semver": "^7.3.8",
"tap": "^16.3.8",
"tap": "^21.1.0",
"unified": "^10.1.2",
"yaml": "^2.2.1"
},
Expand Down
3 changes: 2 additions & 1 deletion lib/base-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ class BaseCommand {
let results = ''
let line = ''
for (const param of params) {
/* istanbul ignore next */
/* c8 ignore start */
if (seenExclusive.has(param)) {
continue
}
/* c8 ignore stop */
const { exclusive } = definitions[param]
let paramUsage = `${definitions[param].usage}`
if (exclusive) {
Expand Down
5 changes: 3 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
try {
const { enableCompileCache } = require('node:module')
/* istanbul ignore next */
/* c8 ignore start */
if (enableCompileCache) {
enableCompileCache()
}
} catch (e) { /* istanbul ignore next */ }
/* c8 ignore stop */
} catch (e) { /* c8 ignore next */ }

const validateEngines = require('./cli/validate-engines.js')
const cliEntry = require('node:path').resolve(__dirname, 'cli/entry.js')
Expand Down
3 changes: 2 additions & 1 deletion lib/cli/validate-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = (process, getCli) => {

// coverage ignored because this is only hit in very unsupported node versions
// and it's a best effort attempt to show something nice in those cases
/* istanbul ignore next */
/* c8 ignore start */
const syntaxErrorHandler = (err) => {
if (err instanceof SyntaxError) {
// eslint-disable-next-line no-console
Expand All @@ -28,6 +28,7 @@ module.exports = (process, getCli) => {
}
throw err
}
/* c8 ignore stop */

process.on('uncaughtException', syntaxErrorHandler)
process.on('unhandledRejection', syntaxErrorHandler)
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ const dumpScript = async (p) => {
// errors, so casually. But, without this, `. <(npm completion)`
// can never ever work on OS X.
// TODO Ignoring coverage, see 'non EPIPE errors cause failures' test.
/* istanbul ignore next */
if (er.errno === 'EPIPE') {
if (er.errno === 'EPIPE') /* c8 ignore next */ {
res()
} else {
rej(er)
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@ ${defData}
return // if validate doesn't throw we have nothing to do
} catch (err) {
// coverage skipped because we don't need to test rethrowing errors
// istanbul ignore next
/* c8 ignore start */
if (err.code !== 'ERR_INVALID_AUTH') {
throw err
}
/* c8 ignore stop */

problems = err.problems
}
Expand All @@ -310,12 +311,11 @@ ${defData}
output.standard('The following configuration problems have been repaired:\n')
const summary = problems.map(({ action, from, to, key, where }) => {
// coverage disabled for else branch because it is intentionally omitted
// istanbul ignore else
if (action === 'rename') {
// we keep track of which configs were modified here so we know what to save later
locations.push(where)
return `~ \`${from}\` renamed to \`${to}\` in ${where} config`
} else if (action === 'delete') {
} /* c8 ignore next */ else if (action === 'delete') {
locations.push(where)
return `- \`${key}\` deleted from ${where} config`
}
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ class Edit extends BaseCommand {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
if (args.length !== 1) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class Explain extends ArboristWorkspaceCmd {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
if (!args.length) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class Explore extends BaseCommand {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
if (args.length < 1 || !args[0]) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class Fund extends ArboristWorkspaceCmd {
}

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
const spec = args[0]
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ class Get extends BaseCommand {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts) {
const Config = Npm.cmd('config')
return Config.completion(opts)
}
/* c8 ignore stop */

async exec (args) {
return this.npm.exec('config', ['get'].concat(args))
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class HelpSearch extends BaseCommand {

// coverage is ignored here because the contents of results are
// nondeterministic due to either glob or readFiles or Object.entries
return results.sort(/* istanbul ignore next */ (a, b) =>
return results.sort(/* c8 ignore next */ (a, b) =>
a.found.length > b.found.length ? -1
: a.found.length < b.found.length ? 1
: a.totalHits > b.totalHits ? -1
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ class Link extends ArboristWorkspaceCmd {
const argFound = [...nodes].every(node => {
// TODO: write tests for unmatching version specs, this is hard to test
// atm but should be simple once we have a mocked registry again
if (arg.name !== node.name /* istanbul ignore next */ || (
if (arg.name !== node.name /* c8 ignore next */ || (
arg.version &&
/* istanbul ignore next */
/* c8 ignore next */
!semver.satisfies(node.version, arg.version)
)) {
foundNodes.push(node)
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class LS extends ArboristWorkspaceCmd {
]

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
const all = this.npm.config.get('all')
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ class Rebuild extends ArboristWorkspaceCmd {
static usage = ['[<package-spec>] ...]']

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
const globalTop = resolve(this.npm.globalDir, '..')
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ const unknownHostedUrl = url => {
pathname,
} = new URL(url)

/* istanbul ignore next - URL ctor should prevent this */
/* c8 ignore start - URL ctor should prevent this */
if (!protocol || !hostname) {
return null
}
/* c8 ignore stop */

const proto = /(git\+)http:$/.test(protocol) ? 'http:' : 'https:'
const path = pathname.replace(/\.git$/, '')
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/sbom.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const detectErrors = (node) => {
}

if (edge.invalid) {
/* istanbul ignore next */
/* c8 ignore next */
const spec = edge.spec || '*'
const from = edge.from.pkgid
errors.push(`invalid: ${edge.to.pkgid}, ${spec} required by ${from}`)
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ class Set extends BaseCommand {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts) {
const Config = Npm.cmd('config')
return Config.completion(opts)
}
/* c8 ignore stop */

async exec (args) {
if (!args.length) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class Uninstall extends ArboristWorkspaceCmd {
static ignoreImplicitWorkspace = false

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
if (!args.length) {
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ class Update extends ArboristWorkspaceCmd {
static usage = ['[<pkg>...]']

// TODO
/* istanbul ignore next */
/* c8 ignore start */
static async completion (opts, npm) {
const completion = require('../utils/installed-deep.js')
return completion(npm, opts)
}
/* c8 ignore stop */

async exec (args) {
const update = args.length === 0 ? true : args
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ const LEVEL_METHODS = {
const setBlocking = (stream) => {
// Copied from https://github.com/yargs/set-blocking
// https://raw.githubusercontent.com/yargs/set-blocking/master/LICENSE.txt
/* istanbul ignore next - we trust that this works */
/* c8 ignore start - we trust that this works */
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(true)
}
/* c8 ignore stop */
return stream
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const colorType = (type, chalk) => {
: type === 'bundled' ? chalk.underline.cyan
: type === 'workspace' ? chalk.blueBright
: type === 'overridden' ? chalk.dim
: /* istanbul ignore next */ s => s
: /* c8 ignore next */ s => s
return style(type)
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/explain-eresolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const explain = (expl, chalk, depth) => {
out.push('Found: ' + explainNode(peerConflict.current, depth, chalk))
} else if (currentEdge) {
out.push('Found: ' + explainEdge(currentEdge, depth, chalk))
} else /* istanbul ignore else - should always have one */ if (edge) {
} else /* c8 ignore next - should always have one */ if (edge) {
out.push('Found: ' + explainEdge(edge, depth, chalk))
}

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/sbom-cyclonedx.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const toCyclonedxItem = (node, { packageType }) => {
if (node.integrity) {
const integrity = ssri.parse(node.integrity, { single: true })
component.hashes = [{
alg: ALGO_MAP[integrity.algorithm] || /* istanbul ignore next */ 'SHA-512',
alg: ALGO_MAP[integrity.algorithm] || /* c8 ignore next */ 'SHA-512',
content: integrity.hexDigest(),
}]
}
Expand Down Expand Up @@ -188,7 +188,7 @@ const isGitNode = (node) => {
const { type } = npa(node.resolved)
return type === 'git' || type === 'hosted'
} catch {
/* istanbul ignore next */
/* c8 ignore next */
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/sbom-spdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const isGitNode = (node) => {
const { type } = npa(node.resolved)
return type === 'git' || type === 'hosted'
} catch {
/* istanbul ignore next */
/* c8 ignore next */
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion mock-globals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
"devDependencies": {
"@npmcli/eslint-config": "^5.0.1",
"@npmcli/template-oss": "4.24.4",
"tap": "^16.3.8"
"tap": "^21.1.0"
}
}
2 changes: 1 addition & 1 deletion mock-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
"nock": "^13.3.3",
"npm-package-arg": "^12.0.0",
"pacote": "^21.0.0",
"tap": "^16.3.8"
"tap": "^21.1.0"
}
}
2 changes: 1 addition & 1 deletion node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ __pycache__
.babelrc*
.nyc_output
.gitkeep
*.map
*.d.ts.map
*.ts
*.png
*.jpg
Loading
Loading