Skip to content

Commit 178f138

Browse files
Guillaume Chauyyx990803
Guillaume Chau
authored andcommitted
Default gets the data as argument (#273)
* Default gets the data as argument * Trailing space
1 parent 22d9be3 commit 178f138

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: lib/ask.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ function prompt (data, key, prompt, done) {
3636
if (prompt.when && !evaluate(prompt.when, data)) {
3737
return done()
3838
}
39+
40+
var promptDefault = prompt.default
41+
if (typeof prompt.default === 'function') {
42+
promptDefault = function () {
43+
return prompt.default.bind(this)(data)
44+
}
45+
}
46+
3947
inquirer.prompt([{
4048
type: promptMapping[prompt.type] || prompt.type,
4149
name: key,
4250
message: prompt.message || prompt.label || key,
43-
default: prompt.default,
51+
default: promptDefault,
4452
choices: prompt.choices || [],
4553
validate: prompt.validate || function () { return true }
4654
}], function (answers) {

0 commit comments

Comments
 (0)