re-use same package if already downloaded

This commit is contained in:
Iuri Matias 2017-12-16 17:36:52 -05:00
parent f90321a23e
commit 158fb1414a
1 changed files with 15 additions and 0 deletions

View File

@ -77,6 +77,21 @@ class Npm {
getPackageVersion(packageName, version, returnContent, getFromGit, callback) {
let self = this;
let npmRegistry = "https://registry.npmjs.org/" + packageName + "/" + version;
let packageDirectory = './.embark/versions/' + packageName + '/' + version + '/';
if (fs.existsSync(packageDirectory)) {
let content;
if (getFromGit && returnContent) {
let distFile = packageDirectory + packageName + ".js";
content = fs.readFileSync(distFile).toString();
} else if (returnContent) {
let distFile = packageDirectory + returnContent;
content = fs.readFileSync(distFile).toString();
} else {
content = packageDirectory;
}
return callback(null, content);
}
utils.httpsGet(npmRegistry, function (err, body) {
if (err) {