Skip to content

Commit

Permalink
fix(init): don't ask to install prettier when using --force (#3720)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Apr 9, 2023
1 parent 72fc547 commit 72d11c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/generators/src/init-generator.ts
Expand Up @@ -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) {
Expand Down
33 changes: 22 additions & 11 deletions smoketests/missing-packages/prettier.test.js
Expand Up @@ -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;
};
Expand All @@ -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";

0 comments on commit 72d11c9

Please sign in to comment.