cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwbro...@apache.org
Subject git commit: [CB-3939] Fix create to not replace existing config.xml.
Date Thu, 20 Jun 2013 00:33:30 GMT
Updated Branches:
  refs/heads/master2 fb43f38be -> 9379d3310


[CB-3939] Fix create to not replace existing config.xml.


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

Branch: refs/heads/master2
Commit: 9379d33104c1128f120b558aaa8d81bb7c59b1f9
Parents: fb43f38
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Wed Jun 19 17:33:11 2013 -0700
Committer: Michael Brooks <michael@michaelbrooks.ca>
Committed: Wed Jun 19 17:33:11 2013 -0700

----------------------------------------------------------------------
 spec/create.spec.js | 22 ++++++++++++++++++++++
 src/create.js       | 10 ++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9379d331/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index 89ebfce..daf9c71 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -130,5 +130,27 @@ describe('create command', function () {
                 done();
             });
         });
+        it('should add a missing www/config.xml', function(done) {
+            exists.andCallFake(function(path) {
+                // return false for config.xml otherwise return true (default spy action)
+                return !path.match('config.xml');
+            });
+            cordova.create(tempDir, function() {
+                expect(shell.cp).toHaveBeenCalledWith(
+                    path.resolve(__dirname, '..', 'templates', 'config.xml'),
+                    jasmine.any(String)
+                );
+                done();
+            });
+        });
+        it('should not replace an existing www/config.xml', function(done) {
+            cordova.create(tempDir, function() {
+                expect(shell.cp).not.toHaveBeenCalledWith(
+                    path.resolve(__dirname, '..', 'templates', 'config.xml'),
+                    jasmine.any(String)
+                );
+                done();
+            });
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/9379d331/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 4dbca3a..b8c54de 100644
--- a/src/create.js
+++ b/src/create.js
@@ -117,11 +117,13 @@ module.exports = function create (dir, id, name, callback) {
             }
         }
         shell.cp('-rf', path.join(www_lib, '*'), www_dir);
-        // Copy over template config.xml (TODO: CB-3771 will remove the need for this)
-        var template_config_xml = path.join(__dirname, '..', 'templates', 'config.xml');
-        shell.cp(template_config_xml, www_dir);
-        // Write out id and name to config.xml
         var configPath = util.projectConfig(dir);
+        // Add template config.xml for apps that are missing it
+        if (!fs.existsSync(configPath)) {
+            var template_config_xml = path.join(__dirname, '..', 'templates', 'config.xml');
+            shell.cp(template_config_xml, www_dir);
+        }
+        // Write out id and name to config.xml
         var config = new util.config_parser(configPath);
         config.packageName(id);
         config.name(name);


Mime
View raw message