Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadDescriptor: function(path, done) {
var context = this,
loadPackage;
path = CORE.path.normalize(path);
loadPackage = CORE.async(function() {
return require.packageFor(path);
});
loadPackage(function(err, pkg) {
if (err) return done(err);
var ret = context.buildDescriptorFromPackage(pkg);
context.addDescriptor(ret, true); // replace whatever is in cache
return done(null, ret);
});
},
}, function(done) {
var loadPackage = CORE.async(function() {
return require.packageFor(desc.path);
});
loadPackage(function(err, pkg) {
if (!err & !pkg) err = packageId + ' is invalid';
if (err) return done(err);
context.source.install(pkg, function(err) {
if (err) return done(err);
if (desc.remote) {
desc.remote.cleanup(desc.path, CORE.err(done));
} else return done();
});
});
})(done);
});