|
|
| module.exports = async (process, validateEngines) => {
|
|
|
| process.title = 'npm'
|
|
|
|
|
| require('graceful-fs').gracefulify(require('node:fs'))
|
|
|
| const satisfies = require('semver/functions/satisfies')
|
| const ExitHandler = require('./exit-handler.js')
|
| const exitHandler = new ExitHandler({ process })
|
| const Npm = require('../npm.js')
|
| const npm = new Npm()
|
| exitHandler.setNpm(npm)
|
|
|
|
|
| const { log, output } = require('proc-log')
|
| log.verbose('cli', process.argv.slice(0, 2).join(' '))
|
| log.info('using', 'npm@%s', npm.version)
|
| log.info('using', 'node@%s', process.version)
|
|
|
|
|
|
|
| validateEngines.off()
|
| exitHandler.registerUncaughtHandlers()
|
|
|
|
|
|
|
| if (!satisfies(validateEngines.node, validateEngines.engines)) {
|
| log.warn('cli', validateEngines.unsupportedMessage)
|
| }
|
|
|
|
|
|
|
| try {
|
| const { exec, command, args } = await npm.load()
|
|
|
| if (!exec) {
|
| return exitHandler.exit()
|
| }
|
|
|
| if (!command) {
|
| output.standard(npm.usage)
|
| process.exitCode = 1
|
| return exitHandler.exit()
|
| }
|
|
|
|
|
|
|
| const nonDashArgs = npm.argv.filter(a => /^[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/.test(a))
|
| if (nonDashArgs.length) {
|
| log.error(
|
| 'arg',
|
| 'Argument starts with non-ascii dash, this is probably invalid:',
|
| require('@npmcli/redact').redactLog(nonDashArgs.join(', '))
|
| )
|
| }
|
|
|
| const execPromise = npm.exec(command, args)
|
|
|
|
|
|
|
| const updateNotifier = require('./update-notifier.js')
|
|
|
| updateNotifier(npm).then((msg) => (npm.updateNotification = msg))
|
|
|
| await execPromise
|
| return exitHandler.exit()
|
| } catch (err) {
|
| return exitHandler.exit(err)
|
| }
|
| }
|
|
|