diff --git a/meta.js b/meta.js index a521f9bdd0..b369ceafca 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,36 @@ module.exports = { }, }, - prompts: { + // 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' + } + } : { // The "real" prompts begin here 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 +80,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 +110,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 +136,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)',