Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/nodejs/npm/lib/commands/ drwxr-xr-x | |
| Viewing file: Select action/file-type: // npm edit <pkg>
// open the package folder in the $EDITOR
const { resolve } = require('path')
const fs = require('graceful-fs')
const { spawn } = require('child_process')
const splitPackageNames = require('../utils/split-package-names.js')
const completion = require('../utils/completion/installed-shallow.js')
const BaseCommand = require('../base-command.js')
class Edit extends BaseCommand {
static description = 'Edit an installed package'
static name = 'edit'
static usage = ['<pkg>[/<subpkg>...]']
static params = ['editor']
// TODO
/* istanbul ignore next */
async completion (opts) {
return completion(this.npm, opts)
}
async exec (args) {
if (args.length !== 1) {
throw this.usageError()
}
const path = splitPackageNames(args[0])
const dir = resolve(this.npm.dir, path)
// graceful-fs does not promisify
await new Promise((resolve, reject) => {
fs.lstat(dir, (err) => {
if (err) {
return reject(err)
}
const [bin, ...args] = this.npm.config.get('editor').split(/\s+/)
const editor = spawn(bin, [...args, dir], { stdio: 'inherit' })
editor.on('exit', (code) => {
if (code) {
return reject(new Error(`editor process exited with code: ${code}`))
}
this.npm.exec('rebuild', [dir]).catch(reject).then(resolve)
})
})
})
}
}
module.exports = Edit
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0034 ]-- |