You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2017/06/05 18:55:17 UTC
cordova-lib git commit: CB-12786: Improve logic for searching plugin
id in case of module already exists in node_modules
Repository: cordova-lib
Updated Branches:
refs/heads/master 64c1d61f4 -> aafe7c773
CB-12786: Improve logic for searching plugin id in case of module already exists in node_modules
This closes #555
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/aafe7c77
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/aafe7c77
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/aafe7c77
Branch: refs/heads/master
Commit: aafe7c773614b09dadcf9efd041a2663d1d7b555
Parents: 64c1d61
Author: Nikita Matrosov <v-...@microsoft.com>
Authored: Mon Jun 5 10:48:38 2017 +0300
Committer: Steve Gill <st...@gmail.com>
Committed: Mon Jun 5 11:37:32 2017 -0700
----------------------------------------------------------------------
cordova-fetch/index.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/aafe7c77/cordova-fetch/index.js
----------------------------------------------------------------------
diff --git a/cordova-fetch/index.js b/cordova-fetch/index.js
index 3ef0bf0..b1d37ec 100644
--- a/cordova-fetch/index.js
+++ b/cordova-fetch/index.js
@@ -148,9 +148,15 @@ function trimID(target) {
target = parts[1];
}
- //If local path exists, set target to final directory
+ // If local path exists, try to get plugin id from package.json or set target to final directory
if (fs.existsSync(target)) {
- target = path.basename(target);
+ var pluginId, pkgJsonPath = path.join(target, 'package.json');
+
+ if (fs.existsSync(pkgJsonPath)) {
+ pluginId = JSON.parse(fs.readFileSync(pkgJsonPath)).name;
+ }
+
+ target = pluginId ? pluginId : path.basename(target);
}
//strip away everything after '@'
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org