Skip to content

Commit

Permalink
Respect falsy overrides (fixes #151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rik Smith-Unna committed Jan 21, 2017
1 parent b732102 commit df42a26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ prompt.getInput = function (prop, callback) {
// Handle overrides here.
// TODO: Make overrides nestable
//
if (prompt.override && prompt.override[propName]) {
if (prompt.override && prompt.override.hasOwnProperty(propName)) {
if (prompt._performValidation(name, prop, prompt.override, schema, -1, callback)) {
return callback(null, prompt.override[propName]);
}
Expand Down
14 changes: 14 additions & 0 deletions test/prompt-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,20 @@ vows.describe('prompt').addBatch({
}
}
}
}).addBatch({
"When using prompt": {
"the get() method": {
"skip prompt with falsy prompt.overide": {
topic: function () {
prompt.override = { coconihet: false }
prompt.get('coconihet', this.callback);
},
"skips prompt and uses overide": function (err, results) {
assert.equal(results.coconihet, false)
}
}
}
}
}).addBatch({
"When using prompt": {
"the addProperties() method": {
Expand Down

0 comments on commit df42a26

Please sign in to comment.