You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2013/08/23 17:58:10 UTC
git commit: CB-4651: Allow default project template to be overridden
by config.json
Updated Branches:
refs/heads/master 0f56fbcda -> 6036bc440
CB-4651: Allow default project template to be overridden by config.json
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/6036bc44
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/6036bc44
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/6036bc44
Branch: refs/heads/master
Commit: 6036bc44037b2d3e0fec40b5c9473741732e8ece
Parents: 0f56fbc
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri Aug 23 11:30:02 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri Aug 23 11:55:13 2013 -0400
----------------------------------------------------------------------
spec/platform.spec.js | 38 ++++++++++++++++++++++++++++++++++++++
src/platform.js | 9 ++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6036bc44/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index cded1c6..0ec7954 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -147,6 +147,44 @@ describe('platform command', function() {
expect(exec.mostRecentCall.args[0]).toMatch(/lib.wp.phonegap.bleeding edge.wp8.bin.create/gi);
expect(exec.mostRecentCall.args[0]).toContain(project_dir);
});
+ it('should use a custom template directory if there is one specified in the configuration', function() {
+ var template_dir = "/tmp/custom-template"
+ load.andCallThrough();
+ config_read.andReturn({
+ lib: {
+ android: {
+ uri: "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
+ version: "3.0.0",
+ id: "cordova",
+ template: template_dir
+ }
+ }
+ });
+ cordova.platform('add', 'android');
+ expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
+ expect(exec.mostRecentCall.args[0]).toContain(project_dir);
+ expect(exec.mostRecentCall.args[0]).toContain(template_dir);
+ });
+ it('should not use a custom template directory if there is not one specified in the configuration', function() {
+ load.andCallThrough();
+ config_read.andReturn({
+ lib: {
+ android: {
+ uri: "https://git-wip-us.apache.org/repos/asf?p=cordova-android.git",
+ version: "3.0.0",
+ id: "cordova",
+ }
+ }
+ });
+ cordova.platform('add', 'android');
+ expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
+ expect(exec.mostRecentCall.args[0]).toContain(project_dir);
+ });
+ it('should not use a custom template directory if there is no user-defined configuration', function() {
+ cordova.platform('add', 'android');
+ expect(exec.mostRecentCall.args[0]).toMatch(/^"[^ ]*" +"[^"]*" +"[^"]*" +"[^"]*"$/g);
+ expect(exec.mostRecentCall.args[0]).toContain(project_dir);
+ });
});
describe('`remove`',function() {
it('should remove a supported and added platform', function() {
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6036bc44/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 19f558a..06b75cc 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -91,9 +91,9 @@ module.exports = function platform(command, targets, callback) {
else throw err;
} else {
if (config_json.lib && config_json.lib[t]) {
- call_into_create(t, projectRoot, cfg, config_json.lib[t].id, config_json.lib[t].version, callback, end);
+ call_into_create(t, projectRoot, cfg, config_json.lib[t].id, config_json.lib[t].version, config_json.lib[t].template, callback, end);
} else {
- call_into_create(t, projectRoot, cfg, 'cordova', platforms[t].version, callback, end);
+ call_into_create(t, projectRoot, cfg, 'cordova', platforms[t].version, null, callback, end);
}
}
});
@@ -198,7 +198,7 @@ function createOverrides(projectRoot, target) {
shell.mkdir('-p', path.join(cordova_util.appDir(projectRoot), 'merges', target));
};
-function call_into_create(target, projectRoot, cfg, id, version, callback, end) {
+function call_into_create(target, projectRoot, cfg, id, version, template_dir, callback, end) {
var output = path.join(projectRoot, 'platforms', target);
// Check if output directory already exists.
@@ -223,6 +223,9 @@ function call_into_create(target, projectRoot, cfg, id, version, callback, end)
var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
var name = cfg.name();
var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output, pkg, name);
+ if (template_dir) {
+ command += ' "' + template_dir + '"';
+ }
events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
shell.exec(command, {silent:true,async:true}, function(code, create_output) {