Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isSafeToRm (parent, target, cb) {
log.silly('gentlyRm', 'parent.path =', parent.path)
log.silly('gentlyRm', 'parent.managed =',
parent.managed && parent.managed.target + ' is in ' + parent.managed.path)
log.silly('gentlyRm', 'target.path = ', target.path)
log.silly('gentlyRm', 'target.symlink =', target.symlink)
log.silly('gentlyRm', 'target.managed =',
target.managed && target.managed.target + ' is in ' + target.managed.path)
log.silly('gentlyRm', 'target.inParent = ', target.inParent)
// The parent directory or something it symlinks to must eventually be in
// a folder that npm maintains.
if (!parent.managed) {
log.verbose('gentlyRm', parent.path,
'is not contained in any diretory npm is known to control or ' +
'any place they link to')
return cb(clobberFail(target.path, 'containing path ' + parent.path +
" isn't under npm's control"))
}
return cb(new Error('May not delete: ' + resolved))
}
var options = { log: log.silly.bind(log, 'vacuum-fs') }
if (npm.config.get('force') || !gently) options.purge = true
if (base) options.base = normalize(resolve(npm.prefix, base))
if (!gently) {
log.verbose('gentlyRm', "don't care about contents; nuking", resolved)
return vacuum(resolved, options, cb)
}
var parent = options.base = normalize(base ? resolve(npm.prefix, base) : npm.prefix)
// is the parent directory managed by npm?
log.silly('gentlyRm', 'verifying', parent, 'is an npm working directory')
some(prefixes, isManaged(parent), function (er, matched) {
if (er) return cb(er)
if (!matched) {
log.error('gentlyRm', 'containing path', parent, "isn't under npm's control")
return clobberFail(resolved, parent, cb)
}
log.silly('gentlyRm', 'containing path', parent, "is under npm's control, in", matched)
// is the target directly contained within the (now known to be
// managed) parent?
if (isInside(resolved, parent)) {
log.silly('gentlyRm', 'deletion target', resolved, 'is under', parent)
log.verbose('gentlyRm', 'vacuuming from', resolved, 'up to', parent)
return vacuum(resolved, options, cb)
}
mapToRegistry(data.name, config, function (er, registryURI, auth, registryBase) {
if (er) return cb(er)
var tarballPath = cachedir + ".tgz"
// we just want the base registry URL in this case
log.verbose("publish", "registryBase", registryBase)
log.silly("publish", "uploading", tarballPath)
data._npmUser = {
name : auth.username,
email : auth.email
}
var params = {
metadata : data,
body : createReadStream(tarballPath),
auth : auth
}
// registry-frontdoor cares about the access level, which is only
// configurable for scoped packages
if (config.get("access")) {
if (!npa(data.name).scope && config.get("access") === "restricted") {
fs.stat(process.env.HOME, function (er, st) {
if (er) {
log.error("makeCacheDir", "homeless?")
return cb(er)
}
cacheStat = st
log.silly("makeCacheDir", "cache dir uid, gid", [st.uid, st.gid])
return mkdir(npm.cache, afterMkdir)
})
passingLog(pattern => {
log.silly(prefix, 'pattern to look for packages: %j', pattern);
})
)
Installer.prototype.loadShrinkwrap = function (cb) {
validate('F', arguments)
log.silly('install', 'loadShrinkwrap')
var installNewModules = !!this.args.length
if (installNewModules) {
readShrinkwrap(this.idealTree, cb)
} else {
readShrinkwrap.andInflate(this.idealTree, cb)
}
}
function (err, stdout, stderr) {
log.silly('find vs2017', 'PS err:', err)
log.silly('find vs2017', 'PS stdout:', stdout)
log.silly('find vs2017', 'PS stderr:', stderr)
if (err)
return callback(new Error('Could not use PowerShell to find VS2017'))
var vsSetup
try {
vsSetup = JSON.parse(stdout)
} catch (e) {
log.silly('find vs2017', e)
return callback(new Error('Could not use PowerShell to find VS2017'))
}
log.silly('find vs2017', 'vsSetup:', vsSetup)
if (vsSetup && vsSetup.log)
log.verbose('find vs2017', vsSetup.log.trimRight())
CMLog.prototype.silly = function(cat, msg) {
if (this.options.noLog) {
this.debug(cat + ": " + msg);
}
else {
log.silly(cat, msg);
}
};
function next (er, data, json, resp) {
if (!er) er = errorResponse(name, resp)
if (er) return cb(er)
log.silly('addNameTag', 'next cb for', name, 'with tag', tag)
engineFilter(data)
if (data['dist-tags'] && data['dist-tags'][tag] &&
data.versions[data['dist-tags'][tag]]) {
var ver = data['dist-tags'][tag]
return addNamed(name, ver, data.versions[ver], cb)
}
if (!explicit && Object.keys(data.versions).length) {
return addNamed(name, '*', data, cb)
}
er = installTargetsError(tag, data)
return cb(er)
}
}
.then(function (stdout) {
log.silly('find-msbuild', 'find vs2017: ', stdout);
var vsSetup = JSON.parse(stdout);
if (!vsSetup || !vsSetup.path || !vsSetup.sdk) {
return Promise.reject('unexpected powershell output');
}
log.silly('find-msbuild', 'found vs2017');
log.silly('find-msbuild', 'path', vsSetup.path);
log.silly('find-msbuild', 'sdk', vsSetup.sdk);
var build = {
path: path.join(vsSetup.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe'),
version: 15
};
log.silly('find-msbuild', 'using following msbuild:');
log.silly('find-msbuild', 'version:', build.version);
log.silly('find-msbuild', 'path:', build.path);
return build;
});
}