xref: /third_party/node/deps/npm/test/index.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/deps/npm/test/
11cb0ef41Sopenharmony_ciconst t = require('tap')
21cb0ef41Sopenharmony_ciconst spawn = require('@npmcli/promise-spawn')
31cb0ef41Sopenharmony_ciconst index = require.resolve('../index.js')
41cb0ef41Sopenharmony_ciconst packageIndex = require.resolve('../')
51cb0ef41Sopenharmony_ciconst { load: loadMockNpm } = require('./fixtures/mock-npm')
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cit.equal(index, packageIndex, 'index is main package require() export')
81cb0ef41Sopenharmony_cit.throws(() => require(index), {
91cb0ef41Sopenharmony_ci  message: 'The programmatic API was removed in npm v8.0.0',
101cb0ef41Sopenharmony_ci})
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cit.test('loading as main module will load the cli', async t => {
131cb0ef41Sopenharmony_ci  const { npm, cache } = await loadMockNpm(t)
141cb0ef41Sopenharmony_ci  const LS = require('../lib/commands/ls.js')
151cb0ef41Sopenharmony_ci  const ls = new LS(npm)
161cb0ef41Sopenharmony_ci  const p = await spawn(process.execPath, [index, 'ls', '-h', '--cache', cache])
171cb0ef41Sopenharmony_ci  t.equal(p.code, 0)
181cb0ef41Sopenharmony_ci  t.equal(p.signal, null)
191cb0ef41Sopenharmony_ci  t.match(p.stdout, ls.usage)
201cb0ef41Sopenharmony_ci})
21

Indexes created Thu Nov 07 10:32:03 CST 2024