Skip to content

Commit

Permalink
Add filter support for optional questions
Browse files Browse the repository at this point in the history
Undefined value is now defined in metalsmith metadata when meta.js "when" property returns false. This makes the filter evaluation works for filters using data that have been skipped in the prompt workflow by using the default value of the field.

Close vuejs#408
  • Loading branch information
Toilal committed Apr 5, 2017
1 parent 182feab commit 1d12c08
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ask.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module.exports = function ask (prompts, data, done) {
function prompt (data, key, prompt, done) {
// skip prompts whose when condition is not met
if (prompt.when && !evaluate(prompt.when, data)) {
// set undefined value to avoid failure on filter evaluations
data[key] = undefined
return done()
}

Expand Down

0 comments on commit 1d12c08

Please sign in to comment.