Skip to content

Commit 84ba860

Browse files
committed
don't get choices until prompt is run
1 parent 98302b6 commit 84ba860

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/prompt.choices-function.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var prompt = new Prompt({
55
name: 'colors',
66
message: 'What are your favorite colors?',
77
choices: function() {
8+
console.log('should be second');
89
return [
910
{name: 'red', category: 'foo'},
1011
{name: 'blue', category: 'bar', disabled: true},
@@ -16,7 +17,7 @@ var prompt = new Prompt({
1617
]
1718
}
1819
});
19-
20+
console.log('should be first');
2021
prompt.run(answers)
2122
.then(function(answer) {
2223
console.log(answer)

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var cyan = require('ansi-cyan');
1111
function Checkbox() {
1212
debug('initializing from <%s>', __filename);
1313
Prompt.apply(this, arguments);
14-
this.choices.options.filterList = true;
1514
this.errorMessage = null;
1615
this.infoMessage = this.options.infoMessage || '(Press '
1716
+ cyan('<space>')
@@ -29,6 +28,7 @@ Prompt.extend(Checkbox);
2928
*/
3029

3130
Checkbox.prototype.renderOutput = function() {
31+
this.choices.options.filterList = true;
3232
return this.choices.render(this.position, this.question.options);
3333
};
3434

0 commit comments

Comments
 (0)