Skip to content
Permalink
Browse files
CB-12517 : pkgjson displayname should equal config's name and pkgjson…
….name should equal config's id

 This closes #3
  • Loading branch information
audreyso authored and stevengill committed Mar 29, 2017
1 parent 2721c00 commit 660056966f976f1e15a523c257eb1df012b51e8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
@@ -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);
}
}
}
@@ -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 = {

0 comments on commit 6600569

Please sign in to comment.