From 7aadca330593b0d9be0061499a5ae65c159303a3 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 18 Jan 2018 23:18:05 +0100 Subject: [PATCH 1/3] skip prompts completely when in a test --- meta.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/meta.js b/meta.js index a521f9bdd0..534b40c492 100644 --- a/meta.js +++ b/meta.js @@ -7,11 +7,12 @@ const { runLintFix, printMessage, } = require('./utils') + const pkg = require('./package.json') const templateVersion = pkg.version -const { addTestAnswers } = require('./scenarios') +const { addTestAnswers, isTest } = require('./scenarios') module.exports = { metalsmith: { @@ -32,27 +33,24 @@ module.exports = { }, }, - prompts: { + // We don'T add prompts if this is running in a test + prompts: isTest ? undefined : { name: { - when: 'isNotTest', type: 'string', required: true, message: 'Project name', }, description: { - when: 'isNotTest', type: 'string', required: false, message: 'Project description', default: 'A Vue.js project', }, author: { - when: 'isNotTest', type: 'string', message: 'Author', }, build: { - when: 'isNotTest', type: 'list', message: 'Vue build', choices: [ @@ -70,17 +68,15 @@ module.exports = { ], }, router: { - when: 'isNotTest', type: 'confirm', message: 'Install vue-router?', }, lint: { - when: 'isNotTest', type: 'confirm', message: 'Use ESLint to lint your code?', }, lintConfig: { - when: 'isNotTest && lint', + when: 'lint', type: 'list', message: 'Pick an ESLint preset', choices: [ @@ -102,12 +98,11 @@ module.exports = { ], }, unit: { - when: 'isNotTest', type: 'confirm', message: 'Set up unit tests', }, runner: { - when: 'isNotTest && unit', + when: 'unit', type: 'list', message: 'Pick a test runner', choices: [ @@ -129,12 +124,10 @@ module.exports = { ], }, e2e: { - when: 'isNotTest', type: 'confirm', message: 'Setup e2e tests with Nightwatch?', }, autoInstall: { - when: 'isNotTest', type: 'list', message: 'Should we run `npm install` for you after the project has been created? (recommended)', From e7916b532b93bd5c99d62af145d747db837788d4 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 18 Jan 2018 23:24:16 +0100 Subject: [PATCH 2/3] trick vue-cli prompt defaults --- meta.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/meta.js b/meta.js index 534b40c492..14dfe26ea2 100644 --- a/meta.js +++ b/meta.js @@ -33,8 +33,20 @@ module.exports = { }, }, - // We don'T add prompts if this is running in a test - prompts: isTest ? undefined : { + // We don't add prompts if this is running in a test + prompts: isTest + ? { // This dummy object is necessary to skpi vue-cli prompt defaults for name and author + name: { + type: 'string', + message: 'Name', + when: 'false' + }, + author: { + type: 'string', + message: 'Author', + when: 'false' + } + } : { name: { type: 'string', required: true, From 1fdcdd976394c671fd98d45e34b29c176203e4fd Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 18 Jan 2018 23:24:33 +0100 Subject: [PATCH 3/3] dito --- meta.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta.js b/meta.js index 14dfe26ea2..b369ceafca 100644 --- a/meta.js +++ b/meta.js @@ -46,7 +46,7 @@ module.exports = { message: 'Author', when: 'false' } - } : { + } : { // The "real" prompts begin here name: { type: 'string', required: true,