Skip to content

Commit 1d12c08

Browse files
committed
Add filter support for optional questions
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 #408
1 parent 182feab commit 1d12c08

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/ask.js

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ module.exports = function ask (prompts, data, done) {
3434
function prompt (data, key, prompt, done) {
3535
// skip prompts whose when condition is not met
3636
if (prompt.when && !evaluate(prompt.when, data)) {
37+
// set undefined value to avoid failure on filter evaluations
38+
data[key] = undefined
3739
return done()
3840
}
3941

0 commit comments

Comments
 (0)