Skip to content
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
3 changes: 2 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = async (process) => {
if (process.argv[1][process.argv[1].length - 1] === 'g')
process.argv.splice(1, 1, 'npm', '-g')

log.verbose('cli', process.argv)
const replaceInfo = require('../lib/utils/replace-info.js')
log.verbose('cli', replaceInfo(process.argv))

log.info('using', 'npm@%s', npm.version)
log.info('using', 'node@%s', process.version)
Expand Down
4 changes: 1 addition & 3 deletions lib/utils/error-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ module.exports = (er, npm) => {
[
'Merge conflict detected in your package.json.',
'',
'Please resolve the package.json conflict and retry the command:',
'',
`$ ${process.argv.join(' ')}`,
'Please resolve the package.json conflict and retry.',
].join('\n'),
])
break
Expand Down
4 changes: 1 addition & 3 deletions tap-snapshots/test/lib/utils/error-message.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,9 +1537,7 @@ Object {
String(
Merge conflict detected in your package.json.

Please resolve the package.json conflict and retry the command:

$ arg v
Please resolve the package.json conflict and retry.
),
],
],
Expand Down
26 changes: 26 additions & 0 deletions test/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ t.test('calling with --versions calls npm version with no args', async t => {
t.strictSame(exitHandlerCalled, [])
})

t.test('logged argv is sanitized', async t => {
const proc = processMock({
argv: ['node', 'npm', 'testcommand', 'https://username:[email protected]/test_url_with_a_password'],
})
const { npm } = mockNpm(t)
const cli = cliMock(npm)

npm.commands.testcommand = (args, cb) => {
cb()
}

await cli(proc)
t.equal(proc.title, 'npm')
t.strictSame(logs, [
'pause',
['verbose', 'cli', [
'node',
'npm',
'testcommand',
'https://username:***@npmjs.org/test_url_with_a_password',
]],
['info', 'using', 'npm@%s', npm.version],
['info', 'using', 'node@%s', process.version],
])
})

t.test('print usage if no params provided', async t => {
const proc = processMock({
argv: ['node', 'npm'],
Expand Down