Server IP : 85.214.239.14 / Your IP : 18.216.156.226 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/lib/node_modules/npm/lib/commands/ |
Upload File : |
const { resolve } = require('node:path') const { output } = require('proc-log') const npa = require('npm-package-arg') const semver = require('semver') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Rebuild extends ArboristWorkspaceCmd { static description = 'Rebuild a package' static name = 'rebuild' static params = [ 'global', 'bin-links', 'foreground-scripts', 'ignore-scripts', ...super.params, ] static usage = ['[<package-spec>] ...]'] // TODO /* istanbul ignore next */ static async completion (opts, npm) { const completion = require('../utils/installed-deep.js') return completion(npm, opts) } async exec (args) { const globalTop = resolve(this.npm.globalDir, '..') const where = this.npm.global ? globalTop : this.npm.prefix const Arborist = require('@npmcli/arborist') const arb = new Arborist({ ...this.npm.flatOptions, path: where, // TODO when extending ReifyCmd // workspaces: this.workspaceNames, }) if (args.length) { // get the set of nodes matching the name that we want rebuilt const tree = await arb.loadActual() const specs = args.map(arg => { const spec = npa(arg) if (spec.rawSpec === '*') { return spec } if (spec.type !== 'range' && spec.type !== 'version' && spec.type !== 'directory') { throw new Error('`npm rebuild` only supports SemVer version/range specifiers') } return spec }) const nodes = tree.inventory.filter(node => this.isNode(specs, node)) await arb.rebuild({ nodes }) } else { await arb.rebuild() } output.standard('rebuilt dependencies successfully') } isNode (specs, node) { return specs.some(spec => { if (spec.type === 'directory') { return node.path === spec.fetchSpec } if (spec.name !== node.name) { return false } if (spec.rawSpec === '' || spec.rawSpec === '*') { return true } const { version } = node.package // TODO: add tests for a package with missing version return semver.satisfies(version, spec.fetchSpec) }) } } module.exports = Rebuild