Skip to content
Draft
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: 2 additions & 0 deletions docs/bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const { paths } = require('../lib/index')

run(paths)
.then((res) => console.error(`Wrote ${res.length} files`))
/* c8 ignore start - covered in istanbul not not in the c8 swap */
.catch((err) => {
process.exitCode = 1
console.error(err)
})
/* c8 ignore stop */
5 changes: 4 additions & 1 deletion docs/lib/check-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ function ensureNavigationComplete (nav, fsPaths, ext) {
// otherwise its unmarked in the nav
if (unmatchedFs[key]) {
delete unmatchedFs[key]
} else {
} /* c8 ignore start - covered in istanbul not not in the c8 swap */ else {
unmatchedNav[key] = true
}
/* c8 ignore stop */
}

const toKeys = (v) => Object.keys(v).sort().map((p) => p.split(posix.sep).join(sep))
Expand All @@ -28,6 +29,7 @@ function ensureNavigationComplete (nav, fsPaths, ext) {

const errors = []

/* c8 ignore start - covered in istanbul not not in the c8 swap */
if (missingNav.length) {
errors.push('The following path(s) exist on disk but are not present in /lib/content/nav.yml:')
errors.push(...missingNav.map(n => ` ${n}`))
Expand All @@ -43,6 +45,7 @@ function ensureNavigationComplete (nav, fsPaths, ext) {
errors.push('Update nav.yml to ensure that all files are listed in the appropriate place.')
throw new Error(errors.join('\n'))
}
/* c8 ignore stop */
}

function getNavigationPaths (entries) {
Expand Down
2 changes: 2 additions & 0 deletions docs/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ const TAGS = {
}

const assertPlaceholder = (src, path, placeholder) => {
/* c8 ignore start - covered in istanbul not not in the c8 swap */
if (!src.includes(placeholder)) {
throw new Error(
`Cannot replace ${placeholder} in ${path} due to missing placeholder`
)
}
/* c8 ignore stop */
return placeholder
}

Expand Down
4 changes: 3 additions & 1 deletion docs/lib/transform-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ function transformHTML (
case 'version':
return version

/* c8 ignore start - covered in istanbul not not in the c8 swap */
default:
throw new Error(`warning: unknown token '${token}' in ${path}`)
/* c8 ignore stop */
}
})

Expand All @@ -62,7 +64,7 @@ function transformHTML (

if (url.startsWith('/')) {
const childDepth = path.split('/').length - 1
const prefix = childDepth > 0 ? '../'.repeat(childDepth) : './'
const prefix = childDepth > 0 ? '../'.repeat(childDepth) : /* c8 ignore start - covered in istanbul not not in the c8 swap */ './' /* c8 ignore stop */

url = url.replace(/^\//, prefix)

Expand Down
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
9 changes: 5 additions & 4 deletions lib/commands/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ class Completion extends BaseCommand {
const comps = await completion(opts, this.npm)
return this.wrap(opts, comps)
}
} catch {
} /* c8 ignore start - covered in istanbul not not in the c8 swap */ catch {
// it wasnt a valid command, so do nothing
}
/* c8 ignore stop */
}

// The command should respond with an array. Loop over that,
Expand Down Expand Up @@ -212,12 +213,12 @@ 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 {
} /* c8 ignore start - covered in istanbul not not in the c8 swap */ else {
rej(er)
}
/* c8 ignore stop */
})

process.stdout.write(d, () => {
Expand Down
10 changes: 6 additions & 4 deletions lib/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ const isProtected = (k) => {
}
// //registry:_authToken or //registry:authToken
for (const p of protected) {
if (k.endsWith(`:${p}`) || k.endsWith(`:_${p}`)) {
if (k.endsWith(`:${p}`) || /* c8 ignore start - covered in istanbul not not in the c8 swap */ k.endsWith(`:_${p}`) /* c8 ignore stop */) {
return true
}
}
/* c8 ignore start - covered in istanbul not not in the c8 swap */
}
/* c8 ignore stop */
return false
}

Expand Down Expand Up @@ -290,10 +292,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 +313,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
2 changes: 2 additions & 0 deletions lib/commands/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ class Diff extends BaseCommand {
for (const edge of node.edgesIn) {
return edge.spec
}
/* c8 ignore start - covered in istanbul not not in the c8 swap */
}
/* c8 ignore stop */

const aSpec = `file:${node.realpath}`

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
5 changes: 4 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 Expand Up @@ -166,7 +167,9 @@ class Fund extends ArboristWorkspaceCmd {
return item.package
}
}
/* c8 ignore start - covered in istanbul not not in the c8 swap */
}
/* c8 ignore stop */
} else {
// tries to retrieve a package from arborist inventory
// by matching resulted package name from the provided spec
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
5 changes: 3 additions & 2 deletions lib/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ 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 */ || (
/* c8 ignore start - covered in istanbul not not in the c8 swap */
arg.version &&
/* istanbul ignore next */
!semver.satisfies(node.version, arg.version)
/* c8 ignore stop */
)) {
foundNodes.push(node)
return true
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
2 changes: 2 additions & 0 deletions lib/commands/star.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class Star extends BaseCommand {
log.verbose('star', data)
return data
}
/* c8 ignore start - covered in istanbul not not in the c8 swap */
}
/* c8 ignore stop */
}

module.exports = Star
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
Loading
Loading