nodejs/deps/npm/test/index.js
npm CLI robot 66b1356ebc
deps: upgrade npm to 9.3.0
PR-URL: https://github.com/nodejs/node/pull/46193
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2023-01-17 03:38:23 +00:00

21 lines
734 B
JavaScript

const t = require('tap')
const spawn = require('@npmcli/promise-spawn')
const index = require.resolve('../index.js')
const packageIndex = require.resolve('../')
const { load: loadMockNpm } = require('./fixtures/mock-npm')
t.equal(index, packageIndex, 'index is main package require() export')
t.throws(() => require(index), {
message: 'The programmatic API was removed in npm v8.0.0',
})
t.test('loading as main module will load the cli', async t => {
const { npm, cache } = await loadMockNpm(t)
const LS = require('../lib/commands/ls.js')
const ls = new LS(npm)
const p = await spawn(process.execPath, [index, 'ls', '-h', '--cache', cache])
t.equal(p.code, 0)
t.equal(p.signal, null)
t.match(p.stdout, ls.usage)
})