Skip to content

Commit 72d11c9

Browse files
authored
fix(init): don't ask to install prettier when using --force (#3720)
1 parent 72fc547 commit 72d11c9

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

packages/generators/src/init-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class InitGenerator<
3333
"installPrettier",
3434
"Do you like to install prettier to format generated configuration?",
3535
true,
36-
false,
36+
this.force,
3737
);
3838

3939
if (installPrettier) {

smoketests/missing-packages/prettier.test.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@ const rimraf = require("rimraf");
66
const os = require("os");
77
const { resolve } = require("path");
88

9-
const prettierTest = async () => {
9+
const prettierTestWithoutForce = async () => {
1010
const packageName = "prettier";
11-
const rootPath = resolve(os.tmpdir(), "./test-assets");
12-
const cliArgs = ["init", rootPath, "--force"];
13-
const logMessage = "Do you like to install prettier to format generated configuration?";
14-
const status = await runTestStdout({ packageName, cliArgs, logMessage });
11+
const rootPath = resolve(os.tmpdir(), "./test-assets-2");
12+
const cliArgs = ["init", rootPath];
13+
const inputs = {
14+
"Which of the following JS solutions do you want to use?": `\n`,
15+
"Do you want to use webpack-dev-server?": `n\n`,
16+
"Do you want to simplify the creation of HTML files for your bundle?": `n\n`,
17+
"Do you want to add PWA support?": `n\n`,
18+
"Which of the following CSS solutions do you want to use?": "\n",
19+
"Do you like to install prettier to format generated configuration?": `n\n`,
20+
"Pick a package manager": "\n",
21+
};
22+
const logMessage =
23+
"Generated configuration may not be properly formatted as prettier is not installed";
24+
const status = await runTestStdoutWithInput({
25+
packageName,
26+
cliArgs,
27+
inputs,
28+
logMessage,
29+
});
1530
rimraf.sync(rootPath);
1631
return status;
1732
};
@@ -20,20 +35,16 @@ const prettierTestWithNoAnswer = async () => {
2035
const packageName = "prettier";
2136
const rootPath = resolve(os.tmpdir(), "./test-assets-2");
2237
const cliArgs = ["init", rootPath, "--force"];
23-
const inputs = {
24-
"Do you like to install prettier to format generated configuration?": "n\n",
25-
};
2638
const logMessage =
2739
"Generated configuration may not be properly formatted as prettier is not installed";
28-
const status = await runTestStdoutWithInput({
40+
const status = await runTestStdout({
2941
packageName,
3042
cliArgs,
31-
inputs,
3243
logMessage,
3344
});
3445
rimraf.sync(rootPath);
3546
return status;
3647
};
3748

38-
module.exports.run = [prettierTest, prettierTestWithNoAnswer];
49+
module.exports.run = [prettierTestWithoutForce, prettierTestWithNoAnswer];
3950
module.exports.name = "Missing prettier";

0 commit comments

Comments
 (0)