mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 07:34:30 +00:00

PR-URL: https://github.com/nodejs/node/pull/41065 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
25 lines
769 B
JavaScript
25 lines
769 B
JavaScript
const t = require('tap')
|
|
const index = require.resolve('../index.js')
|
|
const packageIndex = require.resolve('../')
|
|
|
|
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', t => {
|
|
const cwd = t.testdir()
|
|
const { spawn } = require('child_process')
|
|
const LS = require('../lib/commands/ls.js')
|
|
const ls = new LS({})
|
|
const p = spawn(process.execPath, [index, 'ls', '-h', '--cache', cwd])
|
|
const out = []
|
|
p.stdout.on('data', c => out.push(c))
|
|
p.on('close', (code, signal) => {
|
|
t.equal(code, 0)
|
|
t.equal(signal, null)
|
|
t.match(Buffer.concat(out).toString(), ls.usage)
|
|
t.end()
|
|
})
|
|
})
|