Repository: cordova-create Updated Branches: refs/heads/master 2721c00a2 -> 660056966
CB-12517 : pkgjson displayname should equal config's name and pkgjson.name should equal config's id This closes #3 Project: http://git-wip-us.apache.org/repos/asf/cordova-create/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-create/commit/66005696 Tree: http://git-wip-us.apache.org/repos/asf/cordova-create/tree/66005696 Diff: http://git-wip-us.apache.org/repos/asf/cordova-create/diff/66005696 Branch: refs/heads/master Commit: 660056966f976f1e15a523c257eb1df012b51e8f Parents: 2721c00 Author: Audrey So <[email protected]> Authored: Tue Mar 7 16:07:13 2017 -0800 Committer: Steve Gill <[email protected]> Committed: Wed Mar 29 10:15:27 2017 -0700 ---------------------------------------------------------------------- index.js | 14 ++++++++++++-- spec/create.spec.js | 6 ++++-- 2 files changed, 16 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-create/blob/66005696/index.js ---------------------------------------------------------------------- diff --git a/index.js b/index.js index e25f5cf..cdc6d4e 100644 --- a/index.js +++ b/index.js @@ -287,9 +287,19 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents) { // Update package.json name and version fields if (fs.existsSync(pkgjsonPath)) { var pkgjson = require(pkgjsonPath); + + // Pkjson.displayName should equal config's name. if (cfg.name) { - pkgjson.name = cfg.name.toLowerCase(); + pkgjson.displayName = cfg.name; + } + // Pkjson.name should equal config's id. + if(cfg.id) { + pkgjson.name = cfg.id.toLowerCase(); + } else if(!cfg.id) { + // Use default name. + pkgjson.name = 'helloworld'; } + pkgjson.version = '1.0.0'; fs.writeFileSync(pkgjsonPath, JSON.stringify(pkgjson, null, 4), 'utf8'); } @@ -473,4 +483,4 @@ function writeToConfigJson(project_root, opts, autoPersist) { if (!fs.existsSync(copyDst) && fs.existsSync(copySrc)) { shell.cp(copySrc, projectDir); } - } + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-create/blob/66005696/spec/create.spec.js ---------------------------------------------------------------------- diff --git a/spec/create.spec.js b/spec/create.spec.js index 4cc445e..ddbc64b 100644 --- a/spec/create.spec.js +++ b/spec/create.spec.js @@ -175,7 +175,8 @@ describe('create end-to-end', function() { // Check that we got package.json (the correct one) var pkjson = require(path.join(project, 'package.json')); - expect(pkjson.name).toEqual(appName.toLowerCase()); + // Pkjson.displayName should equal config's name. + expect(pkjson.displayName).toEqual(appName); expect(pkjson.valid).toEqual('true'); // Check that we got the right config.xml @@ -418,7 +419,8 @@ describe('create end-to-end', function() { // Check that we got package.json (the correct one) and it was changed var pkjson = require(path.join(project, 'package.json')); - expect(pkjson.name).toEqual(appName.toLowerCase()); + // Pkjson.name should equal config's id. + expect(pkjson.name).toEqual(appId.toLowerCase()); expect(pkjson.valid).toEqual('true'); } var config = { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
