cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [2/4] git commit: [CB-3939] Fix create to not replace existing config.xml.
Date Thu, 20 Jun 2013 16:29:21 GMT
[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/a6e1947d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/a6e1947d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/a6e1947d

Branch: refs/heads/2.9.x
Commit: a6e1947d9bb97b01d732966574d032b68b353ae8
Parents: 49c27f2
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Wed Jun 19 17:33:11 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Thu Jun 20 09:28:54 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/a6e1947d/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/a6e1947d/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