cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kam...@apache.org
Subject git commit: Recreate "platforms" dir if it was deleted.
Date Tue, 22 Apr 2014 22:27:19 GMT
Repository: cordova-cli
Updated Branches:
  refs/heads/master 396b4f962 -> dafc0f0d6


Recreate "platforms" dir if it was deleted.

If the platforms dir is missing, cordova won't complain any longer. It will
think that no platforms are installed. The dir will be recreated when running
cordova platform add.


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

Branch: refs/heads/master
Commit: dafc0f0d6a47ecbf4c02ce95f32de08a2cd1296c
Parents: 396b4f9
Author: Mark Koudritsky <kamrik@gmail.com>
Authored: Tue Apr 22 18:18:14 2014 -0400
Committer: Mark Koudritsky <kamrik@gmail.com>
Committed: Tue Apr 22 18:18:14 2014 -0400

----------------------------------------------------------------------
 spec/fixtures/base/platforms/.svn | 0
 src/platform.js                   | 7 +++++++
 src/util.js                       | 7 ++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dafc0f0d/spec/fixtures/base/platforms/.svn
----------------------------------------------------------------------
diff --git a/spec/fixtures/base/platforms/.svn b/spec/fixtures/base/platforms/.svn
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dafc0f0d/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 1f21f22..bd20780 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -52,6 +52,13 @@ function add(hooks, projectRoot, targets, opts) {
         return Q.reject(new CordovaError('No platform specified. Please specify a platform
to add. See "platform list".'));
     }
     var config_json = config.read(projectRoot);
+    var platformsDir = path.join(projectRoot, 'platforms');
+
+    // The "platforms" dir is safe to delete, it's almost equivalent to
+    // cordova platfrom rm <list of all platforms>
+    if ( !fs.existsSync(platformsDir)) {
+        shell.mkdir('-p', platformsDir);
+    }
 
     return hooks.fire('before_platform_add', opts)
     .then(function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dafc0f0d/src/util.js
----------------------------------------------------------------------
diff --git a/src/util.js b/src/util.js
index ebc437d..2d3b12a 100644
--- a/src/util.js
+++ b/src/util.js
@@ -103,7 +103,12 @@ exports = module.exports = {
     },
     listPlatforms:function(project_dir) {
         var core_platforms = require('../platforms');
-        return fs.readdirSync(path.join(project_dir, 'platforms')).filter(function(p) {
+        var platforms_dir = path.join(project_dir, 'platforms');
+        if ( !fs.existsSync(platforms_dir)) {
+            return [];
+        }
+        var subdirs = fs.readdirSync(platforms_dir);
+        return subdirs.filter(function(p) {
             return Object.keys(core_platforms).indexOf(p) > -1;
         });
     },


Mime
View raw message