Repository: cordova-lib
Updated Branches:
  refs/heads/master 7d1639a5a -> 42f727f8a


CB-10108 Fixes android frameworks installation/removal

This closes #348


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/42f727f8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/42f727f8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/42f727f8

Branch: refs/heads/master
Commit: 42f727f8acaf1537a09e216df505ef8a99403e5f
Parents: 7d1639a
Author: Vladimir Kotikov <v-vlk...@microsoft.com>
Authored: Wed Dec 2 16:35:46 2015 +0300
Committer: Vladimir Kotikov <v-vlk...@microsoft.com>
Committed: Fri Dec 4 10:42:20 2015 +0300

----------------------------------------------------------------------
 cordova-lib/src/platforms/PlatformApiPoly.js | 28 ++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/42f727f8/cordova-lib/src/platforms/PlatformApiPoly.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/platforms/PlatformApiPoly.js 
b/cordova-lib/src/platforms/PlatformApiPoly.js
index 47277e8..eca00d2 100644
--- a/cordova-lib/src/platforms/PlatformApiPoly.js
+++ b/cordova-lib/src/platforms/PlatformApiPoly.js
@@ -154,7 +154,7 @@ PlatformApiPoly.prototype.getPlatformInfo = function () {
     };
     result.root = self.root;
     result.name = self.platform;
-    result.version = knownPlatforms[self.platform].version;
+    self.version = result.version = self.version || 
getPlatformVersion(self.root) || knownPlatforms[self.platform].version;
     result.projectConfig = self._config;
 
     return result;
@@ -240,6 +240,9 @@ PlatformApiPoly.prototype.addPlugin = function (plugin, 
installOptions) {
 
     installOptions = installOptions || {};
     installOptions.variables = installOptions.variables || {};
+    // CB-10108 platformVersion option is required for proper plugin 
installation
+    installOptions.platformVersion = installOptions.platformVersion ||
+        this.getPlatformInfo().version;
 
     var self = this;
     var actions = new ActionStack();
@@ -296,6 +299,11 @@ PlatformApiPoly.prototype.addPlugin = function (plugin, 
installOptions) {
  */
 PlatformApiPoly.prototype.removePlugin = function (plugin, uninstallOptions) {
 
+    uninstallOptions = uninstallOptions || {};
+    // CB-10108 platformVersion option is required for proper plugin 
installation
+    uninstallOptions.platformVersion = uninstallOptions.platformVersion ||
+        this.getPlatformInfo().version;
+
     var self = this;
     var actions = new ActionStack();
     var projectFile = this._handler.parseProjectFile && 
this._handler.parseProjectFile(this.root);
@@ -696,3 +704,21 @@ function copyCordovaSrc(sourceLib, platformInfo) {
         shell.cp('-rf', cordovaJsSrcPath, platformInfo.locations.platformWww);
     }
 }
+
+/**
+ * Gets platform version from 'version' file
+ *
+ * @param   {String}  platformRoot  Platform location
+ * @return  {String|null}           Stringified version of platform or null
+ *   if it is not possible to retrieve version
+ */
+function getPlatformVersion (platformRoot) {
+    var versionFile = path.join(platformRoot, 'cordova/version');
+
+    if (!fs.existsSync(versionFile)) {
+        return null;
+    }
+
+    var version = shell.cat(versionFile).match(/VERSION\s=\s["'](.*)["'];/m);
+    return version && version[1];
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to