Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F0DD3200C46 for ; Wed, 29 Mar 2017 19:18:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF332160B95; Wed, 29 Mar 2017 17:18:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3F8D2160B5D for ; Wed, 29 Mar 2017 19:18:48 +0200 (CEST) Received: (qmail 4144 invoked by uid 500); 29 Mar 2017 17:18:47 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 4127 invoked by uid 99); 29 Mar 2017 17:18:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Mar 2017 17:18:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2D400DFE34; Wed, 29 Mar 2017 17:18:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cordova-create git commit: CB-12517 : pkgjson displayname should equal config's name and pkgjson.name should equal config's id Date: Wed, 29 Mar 2017 17:18:47 +0000 (UTC) archived-at: Wed, 29 Mar 2017 17:18:49 -0000 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 Authored: Tue Mar 7 16:07:13 2017 -0800 Committer: Steve Gill 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: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org