Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var dist = data.dist
if (!dist) return cb(new Error("No dist in "+data._id+" package"))
if (!dist.tarball) return cb(new Error(
"No dist.tarball in " + data._id + " package"))
if ((response && response.statusCode !== 304) || npm.config.get("force")) {
return fetchit()
}
// we got cached data, so let's see if we have a tarball.
var pkgroot = path.join(npm.cache, name, ver)
var pkgtgz = path.join(pkgroot, "package.tgz")
var pkgjson = path.join(pkgroot, "package", "package.json")
fs.stat(pkgtgz, function (er, s) {
if (!er) {
readJson(pkgjson, function (er, data) {
er = needName(er, data)
er = needVersion(er, data)
if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR")
return cb(er)
if (er) return fetchit()
return cb(null, data)
})
} else return fetchit()
})
function fetchit () {
if (!npm.config.get("registry")) {
return cb(new Error("Cannot fetch: "+dist.tarball))
}
mkdirp(p, function (er, made) {
// it could be that we couldn't create it, because it
// already exists, and is on a read-only fs.
if (er) {
return fs.stat(p, function (er2, st) {
if (er2 || !st.isDirectory()) return cb(er)
return cb(null, made)
})
}
return cb(er, made)
})
}
function copyDirectory(source, dest, overwrite, callback) {
// Allow callback as third arg.
if (typeof overwrite === 'function') {
callback = overwrite;
overwrite = null;
}
fs.stat(source, afterSourceStat);
function afterSourceStat(err, stats) {
if (err) {
return callback(err);
}
if (!stats.isDirectory()) {
return callback(new Error("Source is not a directory: " + source));
}
fs.lstat(dest, afterDestStat);
}
function afterDestStat(err, stats) {
if (err && err.code !== 'ENOENT') {
return callback(err);
}
FsLocal.prototype._propfind = function(err, relPath, depth, next) {
if (err) {
setImmediate(next, err);
return;
}
var localPath = path.join(this.root, relPath),
urlPath = this.normalize(relPath);
if (path.basename(relPath).charAt(0) ===".") {
// Skip hidden files & folders (using UNIX
// convention: XXX do it for Windows too)
setImmediate(next);
return;
}
fs.stat(localPath, (function(err, stat) {
if (err) {
setImmediate(next, err);
return;
}
// minimum common set of properties
var node = {
path: urlPath,
name: path.basename(urlPath),
id: this.encodeFileId(urlPath),
isDir: stat.isDirectory()
};
// Give the top-level node the name (NOT the path) of the mount-point
if (node.name === '') {
node.name = path.basename(this.root);
makeAlbum.then(function (paths) {
t.equal(paths.length, 1)
stat(paths[0], function (er, stats) {
if (er) throw er
createReadStream(paths[0]).pipe(reader(
{ path: paths[0], stats: stats },
new Map(),
function (info) {
var track = info.track
t.ok(track, 'should get back a track')
t.equal(track.file.path, paths[0])
t.equal(track.tags.artist, 'The Necks')
t.equal(track.tags.album, 'Open')
t.equal(track.tags.title, 'Open')
t.equal(track.date, '2012-01-20')
t.equal(track.index, 1)
t.end()
},
function (er) {
function getStats (src, dest, cb) {
if (nodeSupportsBigInt()) {
fs.stat(src, { bigint: true }, (err, srcStat) => {
if (err) return cb(err)
fs.stat(dest, { bigint: true }, (err, destStat) => {
if (err) {
if (err.code === 'ENOENT') return cb(null, { srcStat, destStat: null })
return cb(err)
}
return cb(null, { srcStat, destStat })
})
})
} else {
fs.stat(src, (err, srcStat) => {
if (err) return cb(err)
fs.stat(dest, (err, destStat) => {
if (err) {
if (err.code === 'ENOENT') return cb(null, { srcStat, destStat: null })
return cb(err)
return function (done) {
fs.stat(filename, done)
}
}
files.forEach( function ( filename ) {
var filepath = dir + path.sep + filename;
fs.stat( filepath, function ( err, stats ) {
if ( err ) return cb( err );
if ( stats.isDirectory() ) {
processDir( filepath, function ( err, filepaths ) {
if ( err ) return cb( err );
result.push.apply( result, filepaths );
check();
});
} else {
result.push( filepath );
check();
}
});
});
});
function _copyNode(srcPath, dstPath, next) {
fs.stat(srcPath, function(err, stats) {
if (err) {
setImmediate(next, err);
return;
}
if (stats.isDirectory()) {
_copyDir(srcPath, dstPath, next);
} else if (stats.isFile()){
copyFile(srcPath, dstPath, next);
}
});
}
function _copyDir(srcPath, dstPath, next) {
function guessPython () {
log.verbose('could not find "' + python + '". guessing location')
var rootDir = process.env.SystemDrive || 'C:\\'
if (rootDir[rootDir.length - 1] !== '\\') {
rootDir += '\\'
}
var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe')
log.verbose('ensuring that file exists:', pythonPath)
fs.stat(pythonPath, function (err, stat) {
if (err) {
if (err.code == 'ENOENT') {
failNoPython()
} else {
callback(err)
}
return
}
python = pythonPath
checkPythonVersion()
})
}