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

Commit

Permalink
Browse files Browse the repository at this point in the history
test: ensure npm init forwards arguments (#20372)
PR-URL: #20372
Credit: @jdalton
Reviewed-By: @zkat
  • Loading branch information
jdalton authored and zkat committed Apr 20, 2018
1 parent 9d5d0a1 commit ed81d14
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/tap/init-create.js
Expand Up @@ -59,3 +59,32 @@ test('npm init with scoped packages', function (t) {
t.end()
})
})

test('npm init forwards arguments', function (t) {
var libnpxMock = function () {
return Promise.resolve()
}

npm.load({ loglevel: 'silent' }, function () {
var origArgv = process.argv
var init = requireInject('../../lib/init', {
'libnpx': libnpxMock
})

libnpxMock.parseArgs = function (argv) {
process.argv = origArgv
t.same(argv.slice(4), ['a', 'b', 'c'])
}
process.argv = [
process.argv0,
'NPM_CLI_PATH',
'init',
'pkg-name',
'a', 'b', 'c'
]

init(['pkg-name'], function () {})

t.end()
})
})

0 comments on commit ed81d14

Please sign in to comment.