From 158fb1414a46b3abb4e90b2bf2f9fcccc776bda0 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 16 Dec 2017 17:36:52 -0500 Subject: [PATCH] re-use same package if already downloaded --- lib/pipeline/npm.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/pipeline/npm.js b/lib/pipeline/npm.js index 698c3f33a..907988026 100644 --- a/lib/pipeline/npm.js +++ b/lib/pipeline/npm.js @@ -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) {