cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [4/4] git commit: Slight refactor following mw's merges addition. deleteSvnFolders should only be called once per update_project. fixed tests following the merges addition.
Date Mon, 18 Feb 2013 20:05:40 GMT
Updated Branches:
  refs/heads/merges [created] 8005ae6de


Slight refactor following mw's merges addition. deleteSvnFolders should only be called once
per update_project. fixed tests following the merges addition.


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

Branch: refs/heads/merges
Commit: 8005ae6de96991e82ef3e5ea13d3e67adbd2e86e
Parents: d0e4fe2
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Feb 18 12:05:23 2013 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Mon Feb 18 12:05:23 2013 -0800

----------------------------------------------------------------------
 package.json                            |    2 +-
 spec/build.spec.js                      |   52 --------------------------
 spec/create.spec.js                     |    4 ++
 spec/metadata/android_parser.spec.js    |   52 +++++++++++---------------
 spec/metadata/blackberry_parser.spec.js |   50 ++++++++-----------------
 spec/metadata/ios_parser.spec.js        |   47 +++++++++--------------
 spec/platform.spec.js                   |    3 +-
 src/metadata/android_parser.js          |   16 +++----
 src/metadata/blackberry_parser.js       |   28 +++++++-------
 src/metadata/ios_parser.js              |   19 ++++-----
 src/platform.js                         |   44 +++++++--------------
 11 files changed, 108 insertions(+), 209 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index c236d71..9467b5d 100644
--- a/package.json
+++ b/package.json
@@ -45,7 +45,7 @@
     {"name": "Michael Brooks", "email":"michael@michaelbrooks.ca"},
     {"name": "Braden Shepherdson", "email":"braden@chromium.org"},
     {"name": "Gord Tanner", "email":"gtanner@gmail.com"},
-    {"name": "Tim Kim", "email": "timk@adobe.com"},
+    {"name": "Tim Kim", "email": "timk@adobe.com"}
   ],
   "license": "Apache version 2.0"
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index 36ab63d..c4cc288 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -198,57 +198,5 @@ describe('build command', function() {
                 expect(s).not.toHaveBeenCalledWith('after_build');
             });
         });
-
-    });
-
-    describe('merges', function() {
-        describe('per platform', function() {
-            beforeEach(function() {
-                process.chdir(cordova_project);
-            });
-
-            afterEach(function() {
-                process.chdir(cwd);
-            });
-
-            describe('Android', function() {
-                it('should call android_parser\'s update_overrides', function() {
-                    spyOn(require('shelljs'), 'exec').andReturn({code:0});
-                    var s = spyOn(android_parser.prototype, 'update_overrides');
-
-                    cordova.build('android');
-                    expect(s).toHaveBeenCalled();
-                });
-
-            });
-
-            describe('iOS', function() {
-                it('should call ios_parser\'s update_overrides', function(done) {
-                    var parser = new ios_parser(ios_project_path);
-                    var config = new config_parser(www_config);
-
-                    var s = spyOn(parser, 'update_overrides');
-                    parser.update_project(config, function() {
-                        expect(s).toHaveBeenCalled();
-                        done();
-                    });
-                });
-
-            });
-
-            describe('BlackBerry', function() {
-                it('should call blackberry_parser\'s update_overrides', function(done) {
-                    var parser = new blackberry_parser(blackberry_project_path);
-                    var config = new config_parser(www_config);
-
-                    var s = spyOn(parser, 'update_overrides');
-                    parser.update_project(config, function() {
-                        expect(s).toHaveBeenCalled();
-                        done();
-                    });
-                });
-
-            });
-        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index fcb3e76..ccfd21d 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -18,6 +18,10 @@ describe('create command', function () {
         expect(fs.lstatSync(dotc).isFile()).toBe(true);
         expect(JSON.parse(fs.readFileSync(dotc, 'utf8')).name).toBe("HelloCordova");
         var hooks = path.join(tempDir, '.cordova', 'hooks');
+        var www = path.join(tempDir, 'www');
+        expect(fs.existsSync(www)).toBe(true);
+        var merges = path.join(tempDir, 'merges');
+        expect(fs.existsSync(merges)).toBe(true);
         expect(fs.existsSync(hooks)).toBe(true);
         expect(fs.existsSync(path.join(hooks, 'before_platform_add'))).toBe(true);
         expect(fs.existsSync(path.join(hooks, 'before_prepare'))).toBe(true);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/metadata/android_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/android_parser.spec.js b/spec/metadata/android_parser.spec.js
index 0f965e7..0b3a421 100644
--- a/spec/metadata/android_parser.spec.js
+++ b/spec/metadata/android_parser.spec.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -170,51 +169,34 @@ describe('android project parser', function() {
                 parser.update_www();
                 expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory,
'cordova-android', 'framework', 'assets', 'js', 'cordova.android.js'), 'utf-8'));
             });
-            it('should call out to util.deleteSvnFolders', function() {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_www();
-                expect(spy).toHaveBeenCalled();
-            });
         });
 
         describe('update_overrides method',function() {
+            var merges_path = path.join(project_path, 'merges', 'android');
+            shell.mkdir('-p', merges_path);
+            var newFile = path.join(merges_path, 'merge.js');
+            beforeEach(function() {
+                fs.writeFileSync(newFile, 'alert("sup android only!");', 'utf-8');
+            });
+            afterEach(function() {
+                shell.rm('-rf', path.join(merges_path, 'merge.js'));
+            });
 
             it('should copy a new file from merges into www', function() {
-
-                var newFile = path.join(project_path, 'merges','android', 'merge.js');
-
-                this.after(function() {
-                    shell.rm('-rf', path.join(project_path, 'merges','android','merge.js'));
-                });
-
-                fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
             });
 
             it('should copy a file from merges over a file in www', function() {
-
-                var newFile = path.join(project_path, 'merges','android', 'merge.js');
                 var newFileWWW = path.join(project_path, 'www','merge.js');
-
+                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 this.after(function() {
-                    shell.rm('-rf', path.join(project_path, 'merges','android','merge.js'));
-                    shell.rm('-rf',path.join(project_path,'www','merge.js'));
+                    shell.rm('-rf', newFileWWW);
                 });
 
-                fs.writeFileSync(newFile, 'var foo=2;', 'utf-8');
-                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'merge.js'))).toBe(true);
-                console.log(fs.readFileSync(path.join(android_project_path, 'assets', 'www',
'merge.js')));
-                expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('var
foo=2;');
-            });
-
-
-            it('should call out to util.deleteSvnFolders', function() {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_overrides();
-                expect(spy).toHaveBeenCalled();
+                expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup
android only!");');
             });
         });
 
@@ -229,6 +211,16 @@ describe('android project parser', function() {
                 parser.update_project(config);
                 expect(spyConfig).toHaveBeenCalled();
             });
+            it('should invoke update_overrides', function() {
+                var spyOverrides = spyOn(parser, 'update_overrides');
+                parser.update_project(config);
+                expect(spyOverrides).toHaveBeenCalled();
+            });
+            it('should call deleteSvnFolders', function() {
+                var spySvn = spyOn(util, 'deleteSvnFolders');
+                parser.update_project(config);
+                expect(spySvn).toHaveBeenCalled();
+            });
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/metadata/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js
index 79a5495..e7b6433 100644
--- a/spec/metadata/blackberry_parser.spec.js
+++ b/spec/metadata/blackberry_parser.spec.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -138,59 +137,37 @@ describe('blackberry project parser', function() {
                 var bb_cfg = fs.readFileSync(blackberry_config, 'utf-8');
                 expect(bb_cfg).not.toBe(www_cfg);
             });
-            it('should inject a reference to webworks.js in index.html', function() {
-                parser.update_www();
-                var index = fs.readFileSync(path.join(blackberry_project_path, 'www', 'index.html'),
'utf-8');
-                expect(index).toMatch(/<script type="text\/javascript" src="js\/webworks.js">/i);
-            });
-            it('should call out to util.deleteSvnFolders', function() {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_www();
-                expect(spy).toHaveBeenCalled();
-            });
         });
 
         describe('update_overrides method',function() {
+            var merges_path = path.join(project_path, 'merges', 'blackberry');
+            shell.mkdir('-p', merges_path);
+            var newFile = path.join(merges_path, 'merge.js');
+            beforeEach(function() {
+                fs.writeFileSync(newFile, 'alert("sup blackberry only!");', 'utf-8');
+            });
+            afterEach(function() {
+                shell.rm('-rf', path.join(merges_path, 'merge.js'));
+            });
 
             it('should copy a new file from merges into www', function() {
-
-                var newFile = path.join(project_path, 'merges','blackberry', 'merge.js');
-
-                this.after(function() {
-                    shell.rm('-rf', path.join(project_path, 'merges','blackberry','merge.js'));
-                });
-
-                fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true);
             });
 
             it('should copy a file from merges over a file in www', function() {
-
-                var newFile = path.join(project_path, 'merges','blackberry', 'merge.js');
                 var newFileWWW = path.join(project_path, 'www','merge.js');
-
+                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 this.after(function() {
-                    shell.rm('-rf', path.join(project_path, 'merges','blackberry','merge.js'));
                     shell.rm('-rf',path.join(project_path,'www','merge.js'));
                 });
 
-                fs.writeFileSync(newFile, 'var foo=2;', 'utf-8');
-                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true);
-                expect(fs.readFileSync(path.join(blackberry_project_path, 'www', 'merge.js'),'utf-8')).toEqual('var
foo=2;');
-            });
-
-
-            it('should call out to util.deleteSvnFolders', function() {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_overrides();
-                expect(spy).toHaveBeenCalled();
+                expect(fs.readFileSync(path.join(blackberry_project_path, 'www', 'merge.js'),'utf-8')).toEqual('alert("sup
blackberry only!");');
             });
         });
 
-
         describe('update_project method', function() {
             var cordova_config_path = path.join(project_path, '.cordova', 'config.json');
             var original_config_json = fs.readFileSync(cordova_config_path, 'utf-8');
@@ -217,6 +194,11 @@ describe('blackberry project parser', function() {
                     parser.update_project(config);
                     expect(spyConfig).toHaveBeenCalled();
                 });
+                it('should call out to util.deleteSvnFolders', function() {
+                    var spy = spyOn(util, 'deleteSvnFolders');
+                    parser.update_project(config);
+                    expect(spy).toHaveBeenCalled();
+                });
                 it('should not invoke get_blackberry_environment', function() {
                     var spyEnv = spyOn(parser, 'get_blackberry_environment');
                     parser.update_project(config);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/metadata/ios_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/metadata/ios_parser.spec.js b/spec/metadata/ios_parser.spec.js
index de62b1c..e2ac04f 100644
--- a/spec/metadata/ios_parser.spec.js
+++ b/spec/metadata/ios_parser.spec.js
@@ -159,51 +159,35 @@ describe('ios project parser', function () {
                 parser.update_www();
                 expect(fs.readFileSync(path.join(ios_project_path, 'www', 'cordova.js'),
'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.ios.js'),
'utf-8'));
             });
-            it('should call out to util.deleteSvnFolders', function () {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_www();
-                expect(spy).toHaveBeenCalled();
-            });
         });
 
         describe('update_overrides method', function () {
+            var merges_path = path.join(project_path, 'merges', 'ios');
+            shell.mkdir('-p', merges_path);
+            var newFile = path.join(merges_path, 'merge.js');
+            beforeEach(function() {
+                fs.writeFileSync(newFile, 'alert("sup ios only!");', 'utf-8');
+            });
+            afterEach(function() {
+                shell.rm('-rf', path.join(merges_path, 'merge.js'));
+            });
 
             it('should copy a new file from merges into www', function () {
-
-                var newFile = path.join(project_path, 'merges', 'ios', 'merge.js');
-
-                this.after(function () {
-                    shell.rm('-rf', path.join(project_path, 'merges','ios','merge.js'));
-                });
-
-                fs.writeFileSync(newFile, 'alert("sup");', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true);
             });
 
             it('should copy a file from merges over a file in www', function () {
-
-                var newFile = path.join(project_path, 'merges', 'ios', 'merge.js');
                 var newFileWWW = path.join(project_path, 'www', 'merge.js');
-
+                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 this.after(function () {
-                    shell.rm('-rf', path.join(project_path, 'merges','ios','merge.js'));
-                    shell.rm('-rf', path.join(project_path, 'www', 'merge.js'));
+                    shell.rm('-rf', newFileWWW);
                 });
 
-                fs.writeFileSync(newFile, 'var foo=2;', 'utf-8');
-                fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8');
                 parser.update_overrides();
                 expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true);
-                expect(fs.readFileSync(path.join(ios_project_path, 'www', 'merge.js'), 'utf-8')).toEqual('var
foo=2;');
-            });
-
-            it('should call out to util.deleteSvnFolders', function() {
-                var spy = spyOn(util, 'deleteSvnFolders');
-                parser.update_overrides();
-                expect(spy).toHaveBeenCalled();
+                expect(fs.readFileSync(path.join(ios_project_path, 'www', 'merge.js'), 'utf-8')).toEqual('alert("sup
ios only!");');
             });
-
         });
 
         describe('update_project method', function () {
@@ -221,6 +205,13 @@ describe('ios project parser', function () {
                     done();
                 });
             });
+            it('should call out to util.deleteSvnFolders', function(done) {
+                var spy = spyOn(util, 'deleteSvnFolders');
+                parser.update_project(config, function() {
+                    expect(spy).toHaveBeenCalled();
+                    done();
+                });
+            });
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index c49a53c..4345e1e 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -267,10 +267,11 @@ describe('platform command', function() {
                 cr = spyOn(android_parser, 'check_requirements');
             });
             it('should fire before and after hooks through the hooker module', function()
{
-                spyOn(android_parser.prototype, 'update_project');
+                var a_s = spyOn(android_parser.prototype, 'update_project');
                 cordova.platform('add', 'android');
                 fake_reqs_check();
                 fake_create(path.join(tempDir, 'platforms', 'android'));
+                a_s.mostRecentCall.args[1](); // fake update_project
                 expect(s).toHaveBeenCalledWith('before_platform_add');
                 expect(s).toHaveBeenCalledWith('after_platform_add');
             });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index ccde723..77329be 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -16,6 +16,7 @@
     specific language governing permissions and limitations
     under the License.
 */
+
 var fs            = require('fs'),
     path          = require('path'),
     et            = require('elementtree'),
@@ -139,26 +140,23 @@ module.exports.prototype = {
         // write out android lib's cordova.js
         var jsPath = path.join(util.libDirectory, 'cordova-android', 'framework', 'assets',
'js', 'cordova.android.js');
         fs.writeFileSync(path.join(platformWww, 'cordova.js'), fs.readFileSync(jsPath, 'utf-8'),
'utf-8');
-
-        // delete any .svn folders copied over
-        util.deleteSvnFolders(platformWww);
     },
 
     // update the overrides folder into the www folder
     update_overrides:function() {
         var projectRoot = util.isCordova(this.path);
-        var project_www = path.join(this.path, 'assets','www');
-        var overrides = path.join(projectRoot, 'merges','android');
-        shell.cp('-rf', overrides+'/*',project_www);
-
-        // delete any .svn folders copied over
-        util.deleteSvnFolders(project_www);
+        var overrides = path.join(projectRoot, 'merges', 'android');
+        if (fs.existsSync(overrides)) {
+            shell.cp('-rf', path.join(overrides, '*'), this.www_dir());
+        }
     },
 
     update_project:function(cfg, callback) {
         this.update_from_config(cfg);
         this.update_www();
         this.update_overrides();
+        // delete any .svn folders copied over
+        util.deleteSvnFolders(this.www_dir());
         if (callback) callback();
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index cacc260..eaa9830 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -16,6 +16,7 @@
     specific language governing permissions and limitations
     under the License.
 */
+
 var fs            = require('fs'),
     path          = require('path'),
     et            = require('elementtree'),
@@ -61,9 +62,10 @@ module.exports.prototype = {
     update_project:function(cfg, callback) {
         var self = this;
 
-        self.update_from_config(cfg);
-        self.update_www();
-        self.update_overrides();
+        this.update_from_config(cfg);
+        this.update_www();
+        this.update_overrides();
+        util.deleteSvnFolders(this.www_dir());
 
         // Do we have BB config?
         var projectRoot = util.isCordova(this.path);
@@ -77,10 +79,11 @@ module.exports.prototype = {
                 if (callback) callback();
             });
             return;
+        } else {
+            // Write out config stuff to project.properties file
+            this.write_project_properties();
+            if (callback) callback();
         }
-        // Write out config stuff to project.properties file
-        this.write_project_properties();
-        if (callback) callback();
     },
 
     // Returns the platform-specific www directory.
@@ -91,7 +94,7 @@ module.exports.prototype = {
     update_www:function() {
         var projectRoot = util.isCordova(this.path);
         var www = path.join(projectRoot, 'www');
-        var platformWww = path.join(this.path, 'www');
+        var platformWww = this.www_dir();
 
         var finalWww = path.join(this.path, 'finalwww');
         shell.mkdir('-p', finalWww);
@@ -119,21 +122,19 @@ module.exports.prototype = {
         // Delete the old platform www, and move the final project over
         shell.rm('-rf', platformWww);
         shell.mv(finalWww, platformWww);
-
-        util.deleteSvnFolders(platformWww);
     },
 
     // update the overrides folder into the www folder
     update_overrides:function() {
         var projectRoot = util.isCordova(this.path);
         var platformWww = path.join(this.path, 'www');
-        var overrides = path.join(projectRoot, 'merges','blackberry');
-        shell.cp('-rf', overrides+'/*',platformWww);
-        util.deleteSvnFolders(platformWww);
+        var overrides = path.join(projectRoot, 'merges', 'blackberry');
+        if (fs.existsSync(overrides)) {
+            shell.cp('-rf', path.join(overrides, '*'), platformWww);
+        }
     },
 
     write_project_properties:function() {
-        // TODO: eventually support all blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
 
         var projFile = path.join(this.path, 'project.properties');
@@ -151,7 +152,6 @@ module.exports.prototype = {
         fs.writeFileSync(projFile, props, 'utf-8');
     },
     get_blackberry_environment:function(callback) {
-        // TODO: add other blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index 9cf4450..ac62e73 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -16,6 +16,7 @@
     specific language governing permissions and limitations
     under the License.
 */
+
 var fs            = require('fs'),
     path          = require('path'),
     xcode         = require('xcode'),
@@ -140,29 +141,24 @@ module.exports.prototype = {
     update_www:function() {
         var projectRoot = util.isCordova(this.path);
         var www = path.join(projectRoot, 'www');
-        var project_www = path.join(this.path, 'www');
 
         // remove the stock www folder
-        shell.rm('-rf', project_www);
+        shell.rm('-rf', this.www_dir());
 
         // copy over project www assets
         shell.cp('-rf', www, this.path);
 
         // write out proper cordova.js
-        shell.cp('-f', path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.ios.js'),
path.join(project_www, 'cordova.js'));
-
-        util.deleteSvnFolders(project_www);
+        shell.cp('-f', path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.ios.js'),
path.join(this.www_dir(), 'cordova.js'));
     },
 
     // update the overrides folder into the www folder
     update_overrides:function() {
         var projectRoot = util.isCordova(this.path);
-        var project_www = path.join(this.path, 'www');
-        var overrides = path.join(projectRoot, 'merges','ios');
-        shell.cp('-rf', overrides+'/*',project_www);
-
-        util.deleteSvnFolders(project_www);
-
+        var overrides = path.join(projectRoot, 'merges', 'ios');
+        if (fs.existsSync(overrides)) {
+            shell.cp('-rf', path.join(overrides, '*'), this.www_dir());
+        }
     },
 
     update_project:function(cfg, callback) {
@@ -170,6 +166,7 @@ module.exports.prototype = {
         this.update_from_config(cfg, function() {
             self.update_www();
             self.update_overrides();
+            util.deleteSvnFolders(self.www_dir());
             if (callback) callback();
         });
     }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/8005ae6d/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 604561d..4588c5b 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -28,6 +28,12 @@ var config_parser     = require('./config_parser'),
     blackberry_parser = require('./metadata/blackberry_parser'),
     shell             = require('shelljs');
 
+var parsers = {
+    "android":android_parser,
+    "ios":ios_parser,
+    "blackberry":blackberry_parser
+};
+
 module.exports = function platform(command, targets, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
@@ -39,7 +45,7 @@ module.exports = function platform(command, targets, callback) {
         end;
 
     var createOverrides = function(target){
-        shell.mkdir('-p', path.join('merges',target));
+        shell.mkdir('-p', path.join(projectRoot, 'merges', target));
     };
 
     if (arguments.length === 0) command = 'ls';
@@ -91,34 +97,14 @@ module.exports = function platform(command, targets, callback) {
                                 throw new Error('An error occured during creation of ' +
target + ' sub-project. ' + create_output);
                             }
 
-                            switch(target) {
-                                case 'android':
-                                    var android = new android_parser(output);
-                                    createOverrides(target);
-
-                                    android.update_project(cfg);
-                                    hooks.fire('after_platform_add');
-                                    end();
-                                    break;
-                                case 'ios':
-                                    var ios = new ios_parser(output);
-                                    createOverrides(target);
+                            // create a merges folder
+                            createOverrides(target);
 
-                                    ios.update_project(cfg, function() {
-                                        hooks.fire('after_platform_add');
-                                        end();
-                                    });
-                                    break;
-                                case 'blackberry':
-                                    var bb = new blackberry_parser(output);
-                                    createOverrides(target);
-
-                                    bb.update_project(cfg, function() {
-                                        hooks.fire('after_platform_add');
-                                        end();
-                                    });
-                                    break;
-                            }
+                            var parser = new parsers[target](output);
+                            parser.update_project(cfg, function() {
+                                hooks.fire('after_platform_add');
+                                end();
+                            });
                         });
                     }
                 });
@@ -129,7 +115,7 @@ module.exports = function platform(command, targets, callback) {
             targets.forEach(function(target) {
                 hooks.fire('before_platform_rm');
                 shell.rm('-rf', path.join(projectRoot, 'platforms', target));
-                shell.rm('-rf', path.join(projectRoot,'merges',target));
+                shell.rm('-rf', path.join(projectRoot, 'merges', target));
                 hooks.fire('after_platform_rm');
             });
             break;


Mime
View raw message