Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: edit.js
// npm edit <pkg>
[0] Fix | Delete
// open the package folder in the $EDITOR
[1] Fix | Delete
[2] Fix | Delete
module.exports = edit
[3] Fix | Delete
edit.usage = 'npm edit <pkg>[/<subpkg>...]'
[4] Fix | Delete
[5] Fix | Delete
edit.completion = require('./utils/completion/installed-shallow.js')
[6] Fix | Delete
[7] Fix | Delete
var npm = require('./npm.js')
[8] Fix | Delete
var path = require('path')
[9] Fix | Delete
var fs = require('graceful-fs')
[10] Fix | Delete
var editor = require('editor')
[11] Fix | Delete
var noProgressTillDone = require('./utils/no-progress-while-running').tillDone
[12] Fix | Delete
[13] Fix | Delete
function edit (args, cb) {
[14] Fix | Delete
var p = args[0]
[15] Fix | Delete
if (args.length !== 1 || !p) return cb(edit.usage)
[16] Fix | Delete
var e = npm.config.get('editor')
[17] Fix | Delete
if (!e) {
[18] Fix | Delete
return cb(new Error(
[19] Fix | Delete
"No editor set. Set the 'editor' config, or $EDITOR environ."
[20] Fix | Delete
))
[21] Fix | Delete
}
[22] Fix | Delete
p = p.split('/')
[23] Fix | Delete
// combine scoped parts
[24] Fix | Delete
.reduce(function (parts, part) {
[25] Fix | Delete
if (parts.length === 0) {
[26] Fix | Delete
return [part]
[27] Fix | Delete
}
[28] Fix | Delete
var lastPart = parts[parts.length - 1]
[29] Fix | Delete
// check if previous part is the first part of a scoped package
[30] Fix | Delete
if (lastPart[0] === '@' && !lastPart.includes('/')) {
[31] Fix | Delete
parts[parts.length - 1] += '/' + part
[32] Fix | Delete
} else {
[33] Fix | Delete
parts.push(part)
[34] Fix | Delete
}
[35] Fix | Delete
return parts
[36] Fix | Delete
}, [])
[37] Fix | Delete
.join('/node_modules/')
[38] Fix | Delete
.replace(/(\/node_modules)+/, '/node_modules')
[39] Fix | Delete
var f = path.resolve(npm.dir, p)
[40] Fix | Delete
fs.lstat(f, function (er) {
[41] Fix | Delete
if (er) return cb(er)
[42] Fix | Delete
editor(f, { editor: e }, noProgressTillDone(function (er) {
[43] Fix | Delete
if (er) return cb(er)
[44] Fix | Delete
npm.commands.rebuild(args, cb)
[45] Fix | Delete
}))
[46] Fix | Delete
})
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function