mirror of https://github.com/embarklabs/embark.git
re-use same package if already downloaded
This commit is contained in:
parent
f90321a23e
commit
158fb1414a
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue