Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: init.js
// initialize a package.json file
[0] Fix | Delete
[1] Fix | Delete
module.exports = init
[2] Fix | Delete
[3] Fix | Delete
var path = require('path')
[4] Fix | Delete
var log = require('npmlog')
[5] Fix | Delete
var npa = require('npm-package-arg')
[6] Fix | Delete
var npm = require('./npm.js')
[7] Fix | Delete
var npx = require('libnpx')
[8] Fix | Delete
var initJson = require('init-package-json')
[9] Fix | Delete
var isRegistry = require('./utils/is-registry.js')
[10] Fix | Delete
var output = require('./utils/output.js')
[11] Fix | Delete
var noProgressTillDone = require('./utils/no-progress-while-running').tillDone
[12] Fix | Delete
var usage = require('./utils/usage')
[13] Fix | Delete
[14] Fix | Delete
init.usage = usage(
[15] Fix | Delete
'init',
[16] Fix | Delete
'\nnpm init [--force|-f|--yes|-y|--scope]' +
[17] Fix | Delete
'\nnpm init <@scope> (same as `npx <@scope>/create`)' +
[18] Fix | Delete
'\nnpm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)'
[19] Fix | Delete
)
[20] Fix | Delete
[21] Fix | Delete
function init (args, cb) {
[22] Fix | Delete
if (args.length) {
[23] Fix | Delete
var NPM_PATH = path.resolve(__dirname, '../bin/npm-cli.js')
[24] Fix | Delete
var initerName = args[0]
[25] Fix | Delete
var packageName = initerName
[26] Fix | Delete
if (/^@[^/]+$/.test(initerName)) {
[27] Fix | Delete
packageName = initerName + '/create'
[28] Fix | Delete
} else {
[29] Fix | Delete
var req = npa(initerName)
[30] Fix | Delete
if (req.type === 'git' && req.hosted) {
[31] Fix | Delete
var { user, project } = req.hosted
[32] Fix | Delete
packageName = initerName
[33] Fix | Delete
.replace(user + '/' + project, user + '/create-' + project)
[34] Fix | Delete
} else if (isRegistry(req)) {
[35] Fix | Delete
packageName = req.name.replace(/^(@[^/]+\/)?/, '$1create-')
[36] Fix | Delete
if (req.rawSpec) {
[37] Fix | Delete
packageName += '@' + req.rawSpec
[38] Fix | Delete
}
[39] Fix | Delete
} else {
[40] Fix | Delete
var err = new Error(
[41] Fix | Delete
'Unrecognized initializer: ' + initerName +
[42] Fix | Delete
'\nFor more package binary executing power check out `npx`:' +
[43] Fix | Delete
'\nhttps://www.npmjs.com/package/npx'
[44] Fix | Delete
)
[45] Fix | Delete
err.code = 'EUNSUPPORTED'
[46] Fix | Delete
throw err
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
var npxArgs = [process.argv0, '[fake arg]', '--always-spawn', packageName, ...process.argv.slice(4)]
[50] Fix | Delete
var parsed = npx.parseArgs(npxArgs, NPM_PATH)
[51] Fix | Delete
[52] Fix | Delete
return npx(parsed)
[53] Fix | Delete
.then(() => cb())
[54] Fix | Delete
.catch(cb)
[55] Fix | Delete
}
[56] Fix | Delete
var dir = process.cwd()
[57] Fix | Delete
log.pause()
[58] Fix | Delete
var initFile = npm.config.get('init-module')
[59] Fix | Delete
if (!initJson.yes(npm.config)) {
[60] Fix | Delete
output([
[61] Fix | Delete
'This utility will walk you through creating a package.json file.',
[62] Fix | Delete
'It only covers the most common items, and tries to guess sensible defaults.',
[63] Fix | Delete
'',
[64] Fix | Delete
'See `npm help init` for definitive documentation on these fields',
[65] Fix | Delete
'and exactly what they do.',
[66] Fix | Delete
'',
[67] Fix | Delete
'Use `npm install <pkg>` afterwards to install a package and',
[68] Fix | Delete
'save it as a dependency in the package.json file.',
[69] Fix | Delete
'',
[70] Fix | Delete
'Press ^C at any time to quit.'
[71] Fix | Delete
].join('\n'))
[72] Fix | Delete
}
[73] Fix | Delete
initJson(dir, initFile, npm.config, noProgressTillDone(function (er, data) {
[74] Fix | Delete
log.resume()
[75] Fix | Delete
log.silly('package data', data)
[76] Fix | Delete
if (er && er.message === 'canceled') {
[77] Fix | Delete
log.warn('init', 'canceled')
[78] Fix | Delete
return cb(null, data)
[79] Fix | Delete
}
[80] Fix | Delete
log.info('init', 'written successfully')
[81] Fix | Delete
cb(er, data)
[82] Fix | Delete
}))
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function