Skip to content

Commit 3cbc258

Browse files
committed
chore: test for early version exit
1 parent 7ca6d84 commit 3cbc258

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/lib/cli/entry.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const t = require('tap')
2+
const { readdirSync } = require('fs')
23
const { dirname } = require('path')
34
const { load: loadMockNpm } = require('../../fixtures/mock-npm.js')
45
const tmock = require('../../fixtures/tmock.js')
@@ -170,3 +171,14 @@ t.test('non-ascii dash', async t => {
170171
'arg Argument starts with non-ascii dash, this is probably invalid: \u2010not-a-dash'
171172
)
172173
})
174+
175+
t.test('exit early for --version', async t => {
176+
const { cli, outputs, Npm, cache } = await cliMock(t, {
177+
globals: {
178+
'process.argv': ['node', 'npm', '-v'],
179+
},
180+
})
181+
await cli(process)
182+
t.strictSame(readdirSync(cache), [], 'nothing created in cache')
183+
t.equal(outputs[0], Npm.version)
184+
})

0 commit comments

Comments
 (0)