Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
chore: update linting and all dependencies
Browse files Browse the repository at this point in the history
PR-URL: #313
Credit: @isaacs
Close: #313
Reviewed-by: @wraithgar
  • Loading branch information
isaacs committed Aug 26, 2021
1 parent 7dbc0e3 commit 3cc3a40
Show file tree
Hide file tree
Showing 65 changed files with 1,964 additions and 1,147 deletions.
207 changes: 0 additions & 207 deletions .eslintrc.json

This file was deleted.

6 changes: 4 additions & 2 deletions bin/actual.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ require('./lib/timers.js')
const start = process.hrtime()
new Arborist(options).loadActual(options).then(tree => {
const end = process.hrtime(start)
if (!process.argv.includes('--quiet'))
if (!process.argv.includes('--quiet')) {
print(tree)
}

console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`)
if (options.save)
if (options.save) {
tree.meta.save()
}
if (options.saveHidden) {
tree.meta.hiddenLockfile = true
tree.meta.filename = options.path + '/node_modules/.package-lock.json'
Expand Down
18 changes: 12 additions & 6 deletions bin/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ require('./lib/logging.js')

const Vuln = require('../lib/vuln.js')
const printReport = report => {
for (const vuln of report.values())
for (const vuln of report.values()) {
console.log(printVuln(vuln))
}
if (report.topVulns.size) {
console.log('\n# top-level vulnerabilities')
for (const vuln of report.topVulns.values())
for (const vuln of report.topVulns.values()) {
console.log(printVuln(vuln))
}
}
}

Expand All @@ -37,12 +39,16 @@ const arb = new Arborist(options)
arb.audit(options).then(tree => {
process.emit('timeEnd', 'audit script')
const end = process.hrtime(start)
if (options.fix)
if (options.fix) {
print(tree)
if (!options.quiet)
}
if (!options.quiet) {
printReport(arb.auditReport)
if (options.fix)
}
if (options.fix) {
console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`)
if (tree.meta && options.save)
}
if (tree.meta && options.save) {
tree.meta.save()
}
}).catch(er => console.error(er))
6 changes: 4 additions & 2 deletions bin/funding.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ a.loadVirtual().then(tree => {
const end = process.hrtime(start)
if (!query) {
for (const node of tree.inventory.values()) {
if (node.package.funding)
if (node.package.funding) {
console.log(node.name, node.location, node.package.funding)
}
}
} else {
for (const node of tree.inventory.query('name', query)) {
if (node.package.funding)
if (node.package.funding) {
console.log(node.name, node.location, node.package.funding)
}
}
}
console.error(`read ${tree.inventory.size} deps in ${end[0] * 1000 + end[1] / 1e6}ms`)
Expand Down
3 changes: 2 additions & 1 deletion bin/ideal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ new Arborist(options).buildIdealTree(options).then(tree => {
const end = process.hrtime(start)
print(tree)
console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 10e9}s`)
if (tree.meta && options.save)
if (tree.meta && options.save) {
tree.meta.save()
}
}).catch(er => {
const opt = { depth: Infinity, color: true }
console.error(er.code === 'ERESOLVE' ? inspect(er, opt) : er)
Expand Down
7 changes: 4 additions & 3 deletions bin/lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ const colors = process.stderr.isTTY
const magenta = colors ? msg => `\x1B[35m${msg}\x1B[39m` : m => m
if (loglevel !== 'silent') {
process.on('log', (level, ...args) => {
if (levelMap.get(level) < levelMap.get(loglevel))
if (levelMap.get(level) < levelMap.get(loglevel)) {
return
}
const pref = `${process.pid} ${magenta(level)} `
if (level === 'warn' && args[0] === 'ERESOLVE')
if (level === 'warn' && args[0] === 'ERESOLVE') {
args[2] = inspect(args[2], { depth: 10, colors })
else {
} else {
args = args.map(a => {
return typeof a === 'string' ? a
: inspect(a, { depth: 10, colors })
Expand Down
26 changes: 14 additions & 12 deletions bin/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ for (const arg of process.argv.slice(2)) {
} else if (/^--rm=/.test(arg)) {
options.rm = options.rm || []
options.rm.push(arg.substr('--rm='.length))
} else if (arg === '--global')
} else if (arg === '--global') {
options.global = true
else if (arg === '--global-style')
} else if (arg === '--global-style') {
options.globalStyle = true
else if (arg === '--prefer-dedupe')
} else if (arg === '--prefer-dedupe') {
options.preferDedupe = true
else if (arg === '--legacy-peer-deps')
} else if (arg === '--legacy-peer-deps') {
options.legacyPeerDeps = true
else if (arg === '--force')
} else if (arg === '--force') {
options.force = true
else if (arg === '--update-all') {
} else if (arg === '--update-all') {
options.update = options.update || {}
options.update.all = true
} else if (/^--update=/.test(arg)) {
Expand All @@ -31,9 +31,9 @@ for (const arg of process.argv.slice(2)) {
} else if (/^--omit=/.test(arg)) {
options.omit = options.omit || []
options.omit.push(arg.substr('--omit='.length))
} else if (/^--before=/.test(arg))
} else if (/^--before=/.test(arg)) {
options.before = new Date(arg.substr('--before='.length))
else if (/^-w.+/.test(arg)) {
} else if (/^-w.+/.test(arg)) {
options.workspaces = options.workspaces || []
options.workspaces.push(arg.replace(/^-w/, ''))
} else if (/^--workspace=/.test(arg)) {
Expand All @@ -43,15 +43,17 @@ for (const arg of process.argv.slice(2)) {
const [key, ...v] = arg.replace(/^--/, '').split('=')
const val = v.join('=')
options[key] = val === 'false' ? false : val === 'true' ? true : val
} else if (/^--.+/.test(arg))
} else if (/^--.+/.test(arg)) {
options[arg.replace(/^--/, '')] = true
else if (options.path === undefined)
} else if (options.path === undefined) {
options.path = arg
else
} else {
options._.push(arg)
}
}

if (options.path === undefined)
if (options.path === undefined) {
options.path = '.'
}

console.error(options)
9 changes: 6 additions & 3 deletions bin/lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ const { format } = require('util')
const options = require('./options.js')

process.on('time', name => {
if (timers[name])
if (timers[name]) {
throw new Error('conflicting timer! ' + name)
}
timers[name] = process.hrtime()
})

const dim = process.stderr.isTTY ? msg => `\x1B[2m${msg}\x1B[22m` : m => m
const red = process.stderr.isTTY ? msg => `\x1B[31m${msg}\x1B[39m` : m => m
process.on('timeEnd', name => {
if (!timers[name])
if (!timers[name]) {
throw new Error('timer not started! ' + name)
}
const res = process.hrtime(timers[name])
delete timers[name]
const msg = format(`${process.pid} ${name}`, res[0] * 1e3 + res[1] / 1e6)
if (options.timers !== false)
if (options.timers !== false) {
console.error(dim(msg))
}
})

process.on('exit', () => {
Expand Down
Loading

0 comments on commit 3cc3a40

Please sign in to comment.