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

Remove unused arguments on various function calls #2766

Merged
merged 1 commit into from Mar 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/access.js
Expand Up @@ -10,7 +10,7 @@ const usageUtil = require('./utils/usage.js')
const getIdentity = require('./utils/get-identity.js')

const usage = usageUtil(
'npm access',
'access',
'npm access public [<package>]\n' +
'npm access restricted [<package>]\n' +
'npm access grant <read-only|read-write> <scope:team> [<package>]\n' +
Expand Down
8 changes: 2 additions & 6 deletions lib/ls.js
Expand Up @@ -31,7 +31,7 @@ const usage = usageUtil(

const cmd = (args, cb) => ls(args).then(() => cb()).catch(cb)

const initTree = async ({ arb, args, json }) => {
const initTree = async ({ arb, args }) => {
const tree = await arb.loadActual()
tree[_include] = args.length === 0
tree[_depth] = 0
Expand Down Expand Up @@ -252,7 +252,6 @@ const augmentNodesWithMetadata = ({
args,
currentDepth,
nodeResult,
parseable,
seenNodes,
}) => (node) => {
// if the original edge was a deduped dep, treeverse will fail to
Expand Down Expand Up @@ -285,7 +284,7 @@ const augmentNodesWithMetadata = ({
// _filteredBy is used to apply extra color info to the item that
// was used in args in order to filter
node[_filteredBy] = node[_include] =
filterByPositionalArgs(args, { node: seenNodes.get(node.path), seenNodes })
filterByPositionalArgs(args, { node: seenNodes.get(node.path) })
// _depth keeps track of how many levels deep tree traversal currently is
// so that we can `npm ls --depth=1`
node[_depth] = currentDepth + 1
Expand Down Expand Up @@ -389,8 +388,6 @@ const ls = async (args) => {
const tree = await initTree({
arb,
args,
global,
json,
})

const seenItems = new Set()
Expand Down Expand Up @@ -436,7 +433,6 @@ const ls = async (args) => {
args,
currentDepth: node[_depth],
nodeResult,
parseable,
seenNodes,
}))
},
Expand Down
2 changes: 1 addition & 1 deletion lib/npm.js
Expand Up @@ -193,7 +193,7 @@ const npm = module.exports = new class extends EventEmitter {
this.title = tokrev ? 'npm token revoke' + (this.argv[2] ? ' ***' : '')
: ['npm', ...this.argv].join(' ')

this.color = setupLog(this.config, this)
this.color = setupLog(this.config)
process.env.COLOR = this.color ? '1' : '0'

cleanUpLogFiles(this.cache, this.config.get('logs-max'), log.warn)
Expand Down
7 changes: 4 additions & 3 deletions lib/profile.js
Expand Up @@ -14,9 +14,10 @@ const readUserInfo = require('./utils/read-user-info.js')
const usageUtil = require('./utils/usage.js')

const usage = usageUtil(
'npm profile enable-2fa [auth-only|auth-and-writes]\n',
'npm profile disable-2fa\n',
'npm profile get [<key>]\n',
'profile',
'npm profile enable-2fa [auth-only|auth-and-writes]\n' +
'npm profile disable-2fa\n' +
'npm profile get [<key>]\n' +
'npm profile set <key> <value>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this was removed, we definitely have npm profile set implemented

Copy link
Contributor Author

@sandersn sandersn Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at other calls to usage.js. This call is missing trailing + -- it's not supposed to be a variadic function. I put set back and joined all of the strings with +.

I also noticed that access.js incorrectly had its first argument as 'npm access' instead of 'access'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, we definitely had the param to usage wrong here!

)

Expand Down
6 changes: 3 additions & 3 deletions lib/whoami.js
Expand Up @@ -3,13 +3,13 @@ const output = require('./utils/output.js')
const getIdentity = require('./utils/get-identity.js')
const usageUtil = require('./utils/usage.js')

const cmd = (args, cb) => whoami(args).then(() => cb()).catch(cb)
const cmd = (args, cb) => whoami().then(() => cb()).catch(cb)

const usage = usageUtil('whoami', 'npm whoami [--registry <registry>]\n(just prints username according to given registry)')

const whoami = async ([spec]) => {
const whoami = async () => {
const opts = npm.flatOptions
const username = await getIdentity(opts, spec)
const username = await getIdentity(opts)
output(opts.json ? JSON.stringify(username) : username)
}

Expand Down
9 changes: 4 additions & 5 deletions tap-snapshots/test-lib-utils-npm-usage.js-TAP.test.js
Expand Up @@ -393,11 +393,10 @@ All commands:

prefix npm prefix [-g]

profile npm profile disable-2fa


common options: npm profile get [<key>]

profile npm profile enable-2fa [auth-only|auth-and-writes]
npm profile disable-2fa
npm profile get [<key>]
npm profile set <key> <value>

prune npm prune [[<@scope>/]<pkg>...] [--production]

Expand Down