Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ls): linting cleanup #3454

Merged
merged 1 commit into from
Jun 23, 2021
Merged
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
23 changes: 10 additions & 13 deletions bin/npx-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ process.argv.splice(2, 0, 'exec')
const removedSwitches = new Set([
'always-spawn',
'ignore-existing',
'shell-auto-fallback'
'shell-auto-fallback',
])

const removedOpts = new Set([
'npm',
'node-arg',
'n'
'n',
])

const removed = new Set([
...removedSwitches,
...removedOpts
...removedOpts,
])

const { definitions, shorthands } = require('../lib/utils/config/index.js')
Expand All @@ -40,7 +40,7 @@ const switches = new Set([
'version',
'v',
'help',
'h'
'h',
])

// things that do take a value
Expand All @@ -55,7 +55,7 @@ const opts = new Set([
'shell',
'npm',
'node-arg',
'n'
'n',
])

// break out of loop when we find a positional argument or --
Expand All @@ -65,9 +65,9 @@ let i
let sawRemovedFlags = false
for (i = 3; i < process.argv.length; i++) {
const arg = process.argv[i]
if (arg === '--') {
if (arg === '--')
break
} else if (/^-/.test(arg)) {
else if (/^-/.test(arg)) {
const [key, ...v] = arg.replace(/^-+/, '').split('=')

switch (key) {
Expand All @@ -87,9 +87,8 @@ for (i = 3; i < process.argv.length; i++) {
// resolve shorthands and run again
if (shorthands[key] && !removed.has(key)) {
const a = [...shorthands[key]]
if (v.length) {
if (v.length)
a.push(v.join('='))
}
process.argv.splice(i, 1, ...a)
i--
continue
Expand All @@ -110,9 +109,8 @@ for (i = 3; i < process.argv.length; i++) {
if (removed.has(key)) {
// also remove the value for the cut key.
process.argv.splice(i + 1, 1)
} else {
} else
i++
}
}
} else {
// found a positional arg, put -- in front of it, and we're done
Expand All @@ -121,8 +119,7 @@ for (i = 3; i < process.argv.length; i++) {
}
}

if (sawRemovedFlags) {
if (sawRemovedFlags)
console.error('See `npm help exec` for more information')
}

cli(process)
4 changes: 0 additions & 4 deletions lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ class LS extends ArboristWorkspaceCmd {
dev,
development,
link,
node,
prod,
production,
only,
tree,
}))
.map(mapEdgesToNodes({ seenPaths }))
.concat(appendExtraneousChildren({ node, seenPaths }))
Expand Down Expand Up @@ -392,11 +390,9 @@ const filterByEdgesTypes = ({
dev,
development,
link,
node,
prod,
production,
only,
tree,
}) => {
// filter deps by type, allows for: `npm ls --dev`, `npm ls --prod`,
// `npm ls --link`, `npm ls --only=dev`, etc
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
"posttest": "npm run lint",
"eslint": "eslint",
"lint": "npm run eslint -- test/lib test/bin lib scripts docs smoke-tests",
"lint": "npm run eslint -- test/lib test/bin bin lib scripts docs smoke-tests",
"lintfix": "npm run lint -- --fix",
"prelint": "rimraf test/npm_cache*",
"resetdeps": "bash scripts/resetdeps.sh",
Expand Down