From 1d12c080569ecbe86443b0e6584c719723eaf3f3 Mon Sep 17 00:00:00 2001 From: Toilal Date: Wed, 5 Apr 2017 12:44:16 +0200 Subject: [PATCH] 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 --- lib/ask.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ask.js b/lib/ask.js index 88650b8aac..00b810e136 100644 --- a/lib/ask.js +++ b/lib/ask.js @@ -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() }