diff --git a/lib/index.js b/lib/index.js index d3dd208e..11d42437 100644 --- a/lib/index.js +++ b/lib/index.js @@ -525,7 +525,7 @@ class Generator extends EventEmitter { const storageForQuestion = {}; - const getAnswerFromStorage = function(question) { + const getAnswerFromStorage = question => { let questionStorage = question.storage || storage; questionStorage = typeof questionStorage === 'string' ? this[questionStorage] : questionStorage; diff --git a/test/base.js b/test/base.js index 4eb40d13..097b6ddd 100644 --- a/test/base.js +++ b/test/base.js @@ -1786,6 +1786,17 @@ describe('Base', () => { }); }); + it('saves answers to config when specified as a property name', function() { + return this.dummy + .prompt([{ ...input1Prompt, storage: 'config' }, input2Prompt]) + .then(answers => { + assert.equal(answers.prompt1, 'prompt1NewValue'); + assert.equal(answers.prompt2, 'prompt2NewValue'); + assert.equal(this.dummy.config.get('prompt1'), 'prompt1NewValue'); + assert.equal(this.dummy.config.get('prompt2'), 'prompt2Value'); + }); + }); + it('saves answers to specific storage', function() { return this.dummy .prompt([{ ...input1Prompt, storage: this.dummy.config }, input2Prompt])