diff --git a/packages/generators/src/init-generator.ts b/packages/generators/src/init-generator.ts index 3b6d2dba1fe..e2739fe7b5c 100644 --- a/packages/generators/src/init-generator.ts +++ b/packages/generators/src/init-generator.ts @@ -33,7 +33,7 @@ export default class InitGenerator< "installPrettier", "Do you like to install prettier to format generated configuration?", true, - false, + this.force, ); if (installPrettier) { diff --git a/smoketests/missing-packages/prettier.test.js b/smoketests/missing-packages/prettier.test.js index 0efa7545093..ba2dd9c035c 100644 --- a/smoketests/missing-packages/prettier.test.js +++ b/smoketests/missing-packages/prettier.test.js @@ -6,12 +6,27 @@ const rimraf = require("rimraf"); const os = require("os"); const { resolve } = require("path"); -const prettierTest = async () => { +const prettierTestWithoutForce = async () => { const packageName = "prettier"; - const rootPath = resolve(os.tmpdir(), "./test-assets"); - const cliArgs = ["init", rootPath, "--force"]; - const logMessage = "Do you like to install prettier to format generated configuration?"; - const status = await runTestStdout({ packageName, cliArgs, logMessage }); + const rootPath = resolve(os.tmpdir(), "./test-assets-2"); + const cliArgs = ["init", rootPath]; + const inputs = { + "Which of the following JS solutions do you want to use?": `\n`, + "Do you want to use webpack-dev-server?": `n\n`, + "Do you want to simplify the creation of HTML files for your bundle?": `n\n`, + "Do you want to add PWA support?": `n\n`, + "Which of the following CSS solutions do you want to use?": "\n", + "Do you like to install prettier to format generated configuration?": `n\n`, + "Pick a package manager": "\n", + }; + const logMessage = + "Generated configuration may not be properly formatted as prettier is not installed"; + const status = await runTestStdoutWithInput({ + packageName, + cliArgs, + inputs, + logMessage, + }); rimraf.sync(rootPath); return status; }; @@ -20,20 +35,16 @@ const prettierTestWithNoAnswer = async () => { const packageName = "prettier"; const rootPath = resolve(os.tmpdir(), "./test-assets-2"); const cliArgs = ["init", rootPath, "--force"]; - const inputs = { - "Do you like to install prettier to format generated configuration?": "n\n", - }; const logMessage = "Generated configuration may not be properly formatted as prettier is not installed"; - const status = await runTestStdoutWithInput({ + const status = await runTestStdout({ packageName, cliArgs, - inputs, logMessage, }); rimraf.sync(rootPath); return status; }; -module.exports.run = [prettierTest, prettierTestWithNoAnswer]; +module.exports.run = [prettierTestWithoutForce, prettierTestWithNoAnswer]; module.exports.name = "Missing prettier";