summaryrefslogtreecommitdiff
path: root/deps/npm/test/index.js
blob: 44fb0989df425885bdef733f3f889b12dcb09e9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
})