Skip to content

Commit

Permalink
Merge pull request #1819 from bak/init_private
Browse files Browse the repository at this point in the history
Allow boolean values in bower.json file created by `bower init`
  • Loading branch information
sheerun committed Sep 11, 2015
2 parents 490f63a + 304b639 commit 31b6d59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function readJson(project, logger) {
function saveJson(project, logger, json) {
// Cleanup empty props (null values, empty strings, objects and arrays)
mout.object.forOwn(json, function (value, key) {
if (value == null || mout.lang.isEmpty(value)) {
if (!validConfigValue(value)) {
delete json[key];
}
});
Expand All @@ -81,6 +81,18 @@ function saveJson(project, logger, json) {
});
}

// Test if value is of a type supported by bower.json[0] - Object, Array, String, Boolean - or a Number
// [0]: https://github.com/bower/bower.json-spec
function validConfigValue(val) {
return (
mout.lang.isObject(val) ||
mout.lang.isArray(val) ||
mout.lang.isString(val) ||
mout.lang.isBoolean(val) ||
mout.lang.isNumber(val)
);
}

function setDefaults(config, json) {
var name;
var promise = Q.resolve();
Expand Down
3 changes: 2 additions & 1 deletion test/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe('bower init', function () {
description: 'test-description',
moduleType: 'test-moduleType',
keywords: [ 'test-keyword' ],
license: 'test-license'
license: 'test-license',
private: true
});
});
});
Expand Down

0 comments on commit 31b6d59

Please sign in to comment.