Object.keys(changes).forEach(function(key) { var value = changes[key]; log.silly("_applyVarsSubstitutions()", "key=" + key + " -> value=" + value); content = content.replace("${" + key + "}", value); });
function createConfigFile (err) { if (err) return callback(err) var configFilename = 'config.gypi' var configPath = path.resolve(buildDir, configFilename) log.verbose('build/' + configFilename, 'creating config file') var config = process.config || {} , defaults = config.target_defaults , variables = config.variables // default "config.variables" if (!variables) variables = config.variables = {} // default "config.defaults" if (!defaults) defaults = config.target_defaults = {} // don't inherit the "defaults" from node's `process.config` object. // doing so could cause problems in cases where the `node` executable was // compiled on a different machine (with different lib/include paths) than // the machine where the addon is being built to defaults.cflags = [] defaults.defines = [] defaults.include_dirs = [] defaults.libraries = [] // set the default_configuration prop if ('debug' in gyp.opts) { defaults.default_configuration = gyp.opts.debug ? 'Debug' : 'Release' } if (!defaults.default_configuration) { defaults.default_configuration = 'Release' } // set the target_arch variable // always set arch to 'ia32' on Windows and Mac, // untill we have 64-bit node-webkit exists 64-bit on Window and Mac if (process.platform == 'win32' || process.platform == 'darwin') { variables.target_arch = gyp.opts.arch || 'ia32' } else { variables.target_arch = gyp.opts.arch || process.arch || 'ia32' } // set the toolset for VCExpress users if (win) { if (variables.target_arch != 'ia32') { callback(new Error('Only 32bit libraries can be built on windows')) } } // set the node development directory variables.nodedir = nodeDir // don't copy dev libraries with nodedir option variables.copy_dev_lib = !gyp.opts.nodedir // disable -T "thin" static archives by default variables.standalone_static_library = gyp.opts.thin ? 0 : 1; // loop through the rest of the opts and add the unknown ones as variables. // this allows for module-specific configure flags like: // // $ nw-gyp configure --shared-libxml2 Object.keys(gyp.opts).forEach(function (opt) { if (opt === 'argv') return if (opt in gyp.configDefs) return variables[opt.replace(/-/g, '_')] = gyp.opts[opt] }) // ensures that any boolean values from `process.config` get stringified function boolsToString (k, v) { if (typeof v === 'boolean') return String(v) return v } log.silly('build/' + configFilename, config) // now write out the config.gypi file to the build/ dir var prefix = '# Do not edit. File was generated by nw-gyp\'s "configure" step' , json = JSON.stringify(config, boolsToString, 2) log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) configs.push(configPath) fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs) }
function fetchDirectoryPackageData (dep, where, next) { validate('OSF', arguments) log.silly('fetchDirectoryPackageData', dep.name || dep.rawSpec) readPackageJson(path.join(dep.spec, 'package.json'), false, next) }
npm.commands.link([target.name], function (er, d) { log.silly("localLink", "back from link", [er, d]) cb(er, [resultList(target, where, parent && parent._id)]) })
actionsToLog.forEach(function (action) { log.silly(name, action.map(function (value) { return (value && value.package) ? getPackageId(value) : value }).join(' ')) })
function write (target, targetFolder, context, cb_) { var up = npm.config.get("unsafe-perm") , user = up ? null : npm.config.get("user") , group = up ? null : npm.config.get("group") , family = context.family function cb (er, data) { // cache.unpack returns the data object, and all we care about // is the list of installed packages from that last thing. if (!er) return cb_(er, data) if (npm.config.get("rollback") === false) return cb_(er) npm.rollbacks.push(targetFolder) cb_(er, data) } var bundled = [] log.silly("install write", "writing", target.name, target.version, "to", targetFolder) chain( [ [ cache.unpack, target.name, target.version, targetFolder, null, null, user, group ], function writePackageJSON (cb) { var jsonPath = path.resolve(targetFolder, 'package.json') log.verbose('write', 'writing to', jsonPath) writeFileAtomic(jsonPath, JSON.stringify(target, null, 2) + '\n', cb) }, [ lifecycle, target, "preinstall", targetFolder ], function collectBundled (cb) { if (!target.bundleDependencies) return cb() var bd = path.resolve(targetFolder, "node_modules") fs.readdir(bd, function (er, b) { // nothing bundled, maybe if (er) return cb() bundled = b || [] cb() }) } ] // nest the chain so that we can throw away the results returned // up until this point, since we really don't care about it. , function X (er) { if (er) return cb(er) // before continuing to installing dependencies, check for a shrinkwrap. var opt = { dev: npm.config.get("dev") } readDependencies(context, targetFolder, opt, function (er, data, wrap) { var deps = prepareForInstallMany(data, "dependencies", bundled, wrap, family) var depsTargetFolder = targetFolder var depsContext = { family: family , ancestors: context.ancestors , parent: target , explicit: false , wrap: wrap } var actions = [ [ installManyAndBuild, deps, depsTargetFolder, depsContext ] ] // FIXME: This is an accident waiting to happen! // // 1. If multiple children at the same level of the tree share a // peerDependency that's not in the parent's dependencies, because // the peerDeps don't get added to the family, they will keep // getting reinstalled (worked around by inflighting installOne). // 2. The installer can't safely build at the parent level because // that's already being done by the parent's installAndBuild. This // runs the risk of the peerDependency never getting built. // // The fix: Don't install peerDependencies; require them to be // included as explicit dependencies / devDependencies, and warn // or error when they're missing. See #5080 for more arguments in // favor of killing implicit peerDependency installs with fire. var peerDeps = prepareForInstallMany(data, "peerDependencies", bundled, wrap, family) peerDeps.forEach(function (pd) { warnPeers([ "The peer dependency "+pd+" included from "+data.name+" will no", "longer be automatically installed to fulfill the peerDependency ", "in npm 3+. Your application will need to depend on it explicitly." ], pd+","+data.name) }) // Package scopes cause an addditional tree level which needs to be // considered when resolving a peerDependency's target folder. var pdTargetFolder if (npa(target.name).scope) { pdTargetFolder = path.resolve(targetFolder, '../../..') } else { pdTargetFolder = path.resolve(targetFolder, '../..') } var pdContext = context if (peerDeps.length > 0) { actions.push( [ installMany, peerDeps, pdTargetFolder, pdContext ] ) } chain(actions, cb) }) }) }
return sha.get(p, function (er, shasum) { if (er) return cb(er) log.silly('addLocalTarball', 'shasum (computed)', shasum) addLocalTarball(p, pkgData, shasum, cb) })
app.get('/ding', function (req, res) { log.silly('Server', '%s GET /ding', new Date()) res.end('dong') })
.addListener('finish', function() { log.silly(ModuleName, 'encryptFile: end of writing encrypted file'); defer.resolve(); });
function createConfigFile (err, vsSetup) { if (err) return callback(err) var configFilename = 'config.gypi' var configPath = path.resolve(buildDir, configFilename) log.verbose('build/' + configFilename, 'creating config file') var config = process.config || {} , defaults = config.target_defaults , variables = config.variables // default "config.variables" if (!variables) variables = config.variables = {} // default "config.defaults" if (!defaults) defaults = config.target_defaults = {} // don't inherit the "defaults" from node's `process.config` object. // doing so could cause problems in cases where the `node` executable was // compiled on a different machine (with different lib/include paths) than // the machine where the addon is being built to defaults.cflags = [] defaults.defines = [] defaults.include_dirs = [] defaults.libraries = [] // set the default_configuration prop if ('debug' in gyp.opts) { defaults.default_configuration = gyp.opts.debug ? 'Debug' : 'Release' } if (!defaults.default_configuration) { defaults.default_configuration = 'Release' } // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' // set the node development directory variables.nodedir = nodeDir // don't copy dev libraries with nodedir option variables.copy_dev_lib = !gyp.opts.nodedir // disable -T "thin" static archives by default variables.standalone_static_library = gyp.opts.thin ? 0 : 1 if (vsSetup) { // GYP doesn't (yet) have support for VS2017, so we force it to VS2015 // to avoid pulling a floating patch that has not landed upstream. // Ref: https://chromium-review.googlesource.com/#/c/433540/ gyp.opts.msvs_version = '2015' process.env['GYP_MSVS_VERSION'] = 2015 process.env['GYP_MSVS_OVERRIDE_PATH'] = vsSetup.path defaults['msbuild_toolset'] = 'v141' defaults['msvs_windows_target_platform_version'] = vsSetup.sdk variables['msbuild_path'] = path.join(vsSetup.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe') } // loop through the rest of the opts and add the unknown ones as variables. // this allows for module-specific configure flags like: // // $ node-gyp configure --shared-libxml2 Object.keys(gyp.opts).forEach(function (opt) { if (opt === 'argv') return if (opt in gyp.configDefs) return variables[opt.replace(/-/g, '_')] = gyp.opts[opt] }) // ensures that any boolean values from `process.config` get stringified function boolsToString (k, v) { if (typeof v === 'boolean') return String(v) return v } log.silly('build/' + configFilename, config) // now write out the config.gypi file to the build/ dir var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step' , json = JSON.stringify(config, boolsToString, 2) log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) configs.push(configPath) fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs) }
s.on(e, data => { log.silly('Server', `recv event[${e}] from browser`) this.emit(e, data) })
function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) { function cb (er) { cb_.apply(null, arguments) log.resume() process.nextTick(dequeue) } var conf = { cwd: wd, env: env, stdio: [ 0, 1, 2 ] } if (!unsafe) { conf.uid = uid ^ 0 conf.gid = gid ^ 0 } var sh = 'sh' var shFlag = '-c' if (process.platform === 'win32') { sh = process.env.comspec || 'cmd' shFlag = '/d /s /c' conf.windowsVerbatimArguments = true } log.verbose('lifecycle', logid(pkg, stage), 'PATH:', env[PATH]) log.verbose('lifecycle', logid(pkg, stage), 'CWD:', wd) log.silly('lifecycle', logid(pkg, stage), 'Args:', [shFlag, cmd]) var proc = spawn(sh, [shFlag, cmd], conf) proc.on('error', procError) proc.on('close', function (code, signal) { log.silly('lifecycle', logid(pkg, stage), 'Returned: code:', code, ' signal:', signal) if (signal) { process.kill(process.pid, signal) } else if (code) { var er = new Error('Exit status ' + code) } procError(er) }) process.once('SIGTERM', procKill) function procError (er) { if (er) { log.info('lifecycle', logid(pkg, stage), 'Failed to exec ' + stage + ' script') er.message = pkg._id + ' ' + stage + ': `' + cmd + '`\n' + er.message if (er.code !== 'EPERM') { er.code = 'ELIFECYCLE' } fs.stat(npm.dir, function (statError, d) { if (statError && statError.code === 'ENOENT' && npm.dir.split(path.sep).slice(-1)[0] === 'node_modules') { log.warn('', 'Local package.json exists, but node_modules missing, did you mean to install?') } }) er.pkgid = pkg._id er.stage = stage er.script = cmd er.pkgname = pkg.name } process.removeListener('SIGTERM', procKill) return cb(er) } function procKill () { proc.kill() } }
function gunzTarPerm (tarball, target, dMode, fMode, uid, gid, cb_) { if (!dMode) dMode = npm.modes.exec if (!fMode) fMode = npm.modes.file log.silly("gunzTarPerm", "modes", [dMode.toString(8), fMode.toString(8)]) var cbCalled = false function cb (er) { if (cbCalled) return cbCalled = true cb_(er, target) } var fst = fs.createReadStream(tarball) // figure out who we're supposed to be, if we're not pretending // to be a specific user. if (npm.config.get("unsafe-perm") && process.platform !== "win32") { uid = myUid gid = myGid } function extractEntry (entry) { log.silly("gunzTarPerm", "extractEntry", entry.path) // never create things that are user-unreadable, // or dirs that are user-un-listable. Only leads to headaches. var originalMode = entry.mode = entry.mode || entry.props.mode entry.mode = entry.mode | (entry.type === "Directory" ? dMode : fMode) entry.mode = entry.mode & (~npm.modes.umask) entry.props.mode = entry.mode if (originalMode !== entry.mode) { log.silly( "gunzTarPerm", "modified mode" , [entry.path, originalMode, entry.mode]) } // if there's a specific owner uid/gid that we want, then set that if (process.platform !== "win32" && typeof uid === "number" && typeof gid === "number") { entry.props.uid = entry.uid = uid entry.props.gid = entry.gid = gid } } var extractOpts = { type: "Directory", path: target, strip: 1 } if (process.platform !== "win32" && typeof uid === "number" && typeof gid === "number") { extractOpts.uid = uid extractOpts.gid = gid } extractOpts.filter = function () { // symbolic links are not allowed in packages. if (this.type.match(/^.*Link$/)) { log.warn( "excluding symbolic link" , this.path.substr(target.length + 1) + " -> " + this.linkpath ) return false } return true } fst.on("error", function (er) { if (er) log.error("tar.unpack", "error reading "+tarball) cb(er) }) fst.on("data", function OD (c) { // detect what it is. // Then, depending on that, we'll figure out whether it's // a single-file module, gzipped tarball, or naked tarball. // gzipped files all start with 1f8b08 if (c[0] === 0x1F && c[1] === 0x8B && c[2] === 0x08) { fst .pipe(zlib.Unzip()) .on("error", function (er) { if (er) log.error("tar.unpack", "unzip error "+tarball) cb(er) }) .pipe(tar.Extract(extractOpts)) .on("entry", extractEntry) .on("error", function (er) { if (er) log.error("tar.unpack", "untar error "+tarball) cb(er) }) .on("close", cb) } else if (c.toString().match(/^package\//)) { // naked tar fst .pipe(tar.Extract(extractOpts)) .on("entry", extractEntry) .on("error", function (er) { if (er) log.error("tar.unpack", "untar error "+tarball) cb(er) }) .on("close", cb) } else { // naked js file var jsOpts = { path: path.resolve(target, "index.js") } if (process.platform !== "win32" && typeof uid === "number" && typeof gid === "number") { jsOpts.uid = uid jsOpts.gid = gid } fst .pipe(fstream.Writer(jsOpts)) .on("error", function (er) { if (er) log.error("tar.unpack", "copy error "+tarball) cb(er) }) .on("close", function () { var j = path.resolve(target, "package.json") readJson(j, function (er, d) { if (er) { log.error("not a package", tarball) return cb(er) } fs.writeFile(j, JSON.stringify(d) + "\n", cb) }) }) } // now un-hook, and re-emit the chunk fst.removeListener("data", OD) fst.emit("data", c) }) }
Object.keys(changes).forEach(function(key) { var value = changes[key]; log.silly("_applyRegexpSubstitutions()", "regexp=" + key + " -> value=" + value); var regExp = new RegExp(key, "g"); content = content.replace(regExp, value); });
Installer.prototype.loadShrinkwrap = function (cb) { validate('F', arguments) log.silly('install', 'loadShrinkwrap') readShrinkwrap.andInflate(this.idealTree, cb) }
.addListener('finish', function() { log.silly(ModuleName, 'zipFolderContents: temp zip complete'); defer.resolve(); })
function createConfigFile(err) { if (err) return callback(err) var configFilename = 'config.gypi' var configPath = path.resolve(buildDir, configFilename) log.verbose('build/' + configFilename, 'creating config file') var config = process.config || {} , defaults = config.target_defaults , variables = config.variables if (!defaults) { defaults = config.target_defaults = {} } if (!variables) { variables = config.variables = {} } if (!defaults.cflags) { defaults.cflags = [] } if (!defaults.defines) { defaults.defines = [] } if (!defaults.include_dirs) { defaults.include_dirs = [] } if (!defaults.libraries) { defaults.libraries = [] } // set the default_configuration prop if ('debug' in gyp.opts) { defaults.default_configuration = gyp.opts.debug ? 'Debug' : 'Release' } if (!defaults.default_configuration) { defaults.default_configuration = 'Release' } // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' // set the toolset for VCExpress users if (win) { if (hasVC2012Express && hasWin8SDK) { defaults.msbuild_toolset = 'v110' } else if (hasVCExpress && hasWin71SDK) { defaults.msbuild_toolset = 'Windows7.1SDK' } } // set the node development directory variables.nodedir = nodeDir // don't copy dev libraries with nodedir option variables.copy_dev_lib = !gyp.opts.nodedir // loop through the rest of the opts and add the unknown ones as variables. // this allows for module-specific configure flags like: // // $ node-gyp configure --shared-libxml2 Object.keys(gyp.opts).forEach(function (opt) { if (opt === 'argv') return if (opt in gyp.configDefs) return variables[opt.replace(/-/g, '_')] = gyp.opts[opt] }) // ensures that any boolean values from `process.config` get stringified function boolsToString(k, v) { if (typeof v === 'boolean') return String(v) return v } log.silly('build/' + configFilename, config) // now write out the config.gypi file to the build/ dir var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step' , json = JSON.stringify(config, boolsToString, 2) log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) configs.push(configPath) fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs) }
.addListener('end', function() { log.silly(ModuleName, 'encryptFile: end of encryption stream'); });
}).map(function (d) { var v = packageData[depsKey][d] var t = d + "@" + v log.silly("prepareForInstallMany", "adding", t, "from", packageData.name, depsKey) return t })
.addListener('end', function() { log.silly(ModuleName, 'encryptFile: end of reading unencrypted file'); });
}).then(function(citeprocEngine){ //finish with synchronous processing and responding log.verbose("Async portion done: doing actual citation processing and sending response"); var responseJson = {}; var bib; // Set output format citeprocEngine.cslEngine.setOutputFormat(requestConfig.outputformat); // Add items posted with request citeprocEngine.cslEngine.updateItems(preparedData.reqItemIDs); log.verbose('Items updated'); if (citeprocEngine.cslEngine.opt.sort_citations) { log.verbose("Currently using a sorting style", 1); } citeprocEngine.cslEngine.opt.development_extensions.wrap_url_and_doi = (requestConfig.linkwrap == "1"); log.verbose('citeproc wrap_url_and_doi: ' + citeprocEngine.cslEngine.opt.development_extensions.wrap_url_and_doi); // Switch process depending on bib or citation if (requestConfig.bibliography == "1") { log.verbose('Generating bib'); bib = citeprocEngine.cslEngine.makeBibliography(); log.silly("bib: " + bib); responseJson.bibliography = bib; } if (requestConfig.citations == "1") { log.verbose('Generating citations'); var citations = []; if (preparedData.citationClusters) { for (var i = 0; i < preparedData.citationClusters.length; i++) { citations.push(citeprocEngine.cslEngine.appendCitationCluster(preparedData.citationClusters[i], true)[0]); } } else { log.error("citations requested with no citationClusters"); } log.silly("citations: " + citations); responseJson.citations = citations; } var write = ''; // Write the CSL output to the http response switch(requestConfig.responseformat){ case 'json': response.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' }); write = JSON.stringify(responseJson); break; case 'html': case 'rtf': response.writeHead(200, { 'Content-Type': 'text/' + requestConfig.responseformat + '; charset=utf-8', }); if (bib) { write += bib[0].bibstart + bib[1].join('') + bib[0].bibend; } break; default: } response.write(write, 'utf8'); response.end(); log.verbose("Response sent"); //reset citeproc engine before saving citeprocEngine.cslEngine.sys.items = {}; citeprocEngine.cslEngine.opt.development_extensions.wrap_url_and_doi = false; if (!postedStyle) { engineCache.saveEngine(citeprocEngine, styleUrlObj.href, requestConfig.locale); } }).catch(function(err){
function logAllResources() { log.silly('Total resources in memory: ' + Object.keys(resourceData).length); // log.silly(JSON.stringify(resourceData, null, 4)); }
Installer.prototype.saveToDependencies = function (cb) { validate('F', arguments) if (this.failing) return cb() log.silly('install', 'saveToDependencies') saveRequested(this.args, this.idealTree, cb) }
function requestResource(resourceId) { log.silly('Requested resource (id: ' + resourceId + ') does not exist, sending a resource request'); resourceRequiredPusher.send(JSON.stringify({id: resourceId})); }
Installer.prototype.debugTree = function (name, treeName, cb) { validate('SSF', arguments) log.silly(name, this.prettify(this[treeName]).trim()) cb() }
function gunzTarPerm (tarball, target, dMode, fMode, uid, gid, cb_) { if (!dMode) dMode = npm.modes.exec if (!fMode) fMode = npm.modes.file log.silly('gunzTarPerm', 'modes', [dMode.toString(8), fMode.toString(8)]) var cbCalled = false function cb (er) { if (cbCalled) return cbCalled = true cb_(er, target) } var fst = fs.createReadStream(tarball) fst.on('open', function (fd) { fs.fstat(fd, function (er, st) { if (er) return fst.emit('error', er) if (st.size === 0) { er = new Error('0-byte tarball\n' + 'Please run `npm cache clean`') fst.emit('error', er) } }) }) // figure out who we're supposed to be, if we're not pretending // to be a specific user. if (npm.config.get('unsafe-perm') && process.platform !== 'win32') { uid = myUid gid = myGid } function extractEntry (entry) { log.silly('gunzTarPerm', 'extractEntry', entry.path) // never create things that are user-unreadable, // or dirs that are user-un-listable. Only leads to headaches. var originalMode = entry.mode = entry.mode || entry.props.mode entry.mode = entry.mode | (entry.type === 'Directory' ? dMode : fMode) entry.mode = entry.mode & (~npm.modes.umask) entry.props.mode = entry.mode if (originalMode !== entry.mode) { log.silly('gunzTarPerm', 'modified mode', [entry.path, originalMode, entry.mode]) } // if there's a specific owner uid/gid that we want, then set that if (process.platform !== 'win32' && typeof uid === 'number' && typeof gid === 'number') { entry.props.uid = entry.uid = uid entry.props.gid = entry.gid = gid } } var extractOpts = { type: 'Directory', path: target, strip: 1 } if (process.platform !== 'win32' && typeof uid === 'number' && typeof gid === 'number') { extractOpts.uid = uid extractOpts.gid = gid } var sawIgnores = {} extractOpts.filter = function () { // symbolic links are not allowed in packages. if (this.type.match(/^.*Link$/)) { log.warn('excluding symbolic link', this.path.substr(target.length + 1) + ' -> ' + this.linkpath) return false } // Note: This mirrors logic in the fs read operations that are // employed during tarball creation, in the fstream-npm module. // It is duplicated here to handle tarballs that are created // using other means, such as system tar or git archive. if (this.type === 'File') { var base = path.basename(this.path) if (base === '.npmignore') { sawIgnores[ this.path ] = true } else if (base === '.gitignore') { var npmignore = this.path.replace(/\.gitignore$/, '.npmignore') if (sawIgnores[npmignore]) { // Skip this one, already seen. return false } else { // Rename, may be clobbered later. this.path = npmignore this._path = npmignore } } } return true } fst .on('error', function (er) { if (er) log.error('tar.unpack', 'error reading ' + tarball) cb(er) }) .on('data', function OD (c) { // detect what it is. // Then, depending on that, we'll figure out whether it's // a single-file module, gzipped tarball, or naked tarball. // gzipped files all start with 1f8b08 if (c[0] === 0x1F && c[1] === 0x8B && c[2] === 0x08) { fst .pipe(zlib.Unzip()) .on('error', function (er) { if (er) log.error('tar.unpack', 'unzip error ' + tarball) cb(er) }) .pipe(tar.Extract(extractOpts)) .on('entry', extractEntry) .on('error', function (er) { if (er) log.error('tar.unpack', 'untar error ' + tarball) cb(er) }) .on('close', cb) } else if (hasTarHeader(c)) { // naked tar fst .pipe(tar.Extract(extractOpts)) .on('entry', extractEntry) .on('error', function (er) { if (er) log.error('tar.unpack', 'untar error ' + tarball) cb(er) }) .on('close', cb) } else { // naked js file var jsOpts = { path: path.resolve(target, 'index.js') } if (process.platform !== 'win32' && typeof uid === 'number' && typeof gid === 'number') { jsOpts.uid = uid jsOpts.gid = gid } fst .pipe(fstream.Writer(jsOpts)) .on('error', function (er) { if (er) log.error('tar.unpack', 'copy error ' + tarball) cb(er) }) .on('close', function () { var j = path.resolve(target, 'package.json') readJson(j, function (er, d) { if (er) { log.error('not a package', tarball) return cb(er) } writeFileAtomic(j, JSON.stringify(d) + '\n', cb) }) }) } // now un-hook, and re-emit the chunk fst.removeListener('data', OD) fst.emit('data', c) }) }
cp.stderr.on("data", function(chunk) { log.silly(chunk.toString(), "git archive") })
function add (args, cb) { // this is hot code. almost everything passes through here. // the args can be any of: // ["url"] // ["pkg", "version"] // ["pkg@version"] // ["pkg", "url"] // This is tricky, because urls can contain @ // Also, in some cases we get [name, null] rather // that just a single argument. var usage = "Usage:\n" + " npm cache add <tarball-url>\n" + " npm cache add <pkg>@<ver>\n" + " npm cache add <tarball>\n" + " npm cache add <folder>\n" , name , spec if (args[1] === undefined) args[1] = null // at this point the args length must ==2 if (args[1] !== null) { name = args[0] spec = args[1] } else if (args.length === 2) { spec = args[0] } log.silly("cache add", "name=%j spec=%j args=%j", name, spec, args) if (!name && !spec) return cb(usage) // see if the spec is a url // otherwise, treat as name@version var p = url.parse(spec) || {} log.verbose("parsed url", p) // it could be that we got name@http://blah // in that case, we will not have a protocol now, but if we // split and check, we will. if (!name && !p.protocol && spec.indexOf("@") !== -1) { spec = spec.split("@") name = spec.shift() spec = spec.join("@") return add([name, spec], cb) } switch (p.protocol) { case "http:": case "https:": return addRemoteTarball(spec, null, name, cb) case "git:": case "git+http:": case "git+https:": case "git+rsync:": case "git+ftp:": case "git+ssh:": //p.protocol = p.protocol.replace(/^git([^:])/, "$1") return addRemoteGit(spec, p, name, cb) default: // if we have a name and a spec, then try name@spec // if not, then try just spec (which may try name@"" if not found) if (name) { addNamed(name, spec, cb) } else { addLocal(spec, cb) } } }
this._error = err => { log.silly('fake-registry', err) this.emit('error', err) }
var fileList = session.fileList.filter(function(file) { log.silly("_substitute()", regexp, "matching? file.name:", file.name); return regexp.test(file.name); });