Skip to content

Commit

Permalink
fix: do not use --force when choosing yarn/eslint v8 (#123)
Browse files Browse the repository at this point in the history
* fix: do not use `--force` when choosing yarn

1. yarn v2+ does not support it.
2. yarn v1 can install without the flag.

fixes #122

* refactor output()
  • Loading branch information
aladdin-add authored Jun 4, 2024
1 parent 0e2ecd3 commit b377ad7
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,38 @@ export default [\n${exportContent}];`;
log.info("The config that you've selected requires the following dependencies:\n");
log.info(this.result.devDependencies.join(", "));

const installDevDeps = (await enquirer.prompt({
const questions = [{
type: "toggle",
name: "executeInstallation",
message: "Would you like to install them now?",
enabled: "Yes",
disabled: "No",
initial: 1
})).executeInstallation;

}, {
type: "select",
name: "packageManager",
message: "Which package manager do you want to use?",
initial: 0,
choices: ["npm", "yarn", "pnpm", "bun"],
skip() {
return this.state.answers.executeInstallation === false;
}
}];
const { executeInstallation, packageManager } = (await enquirer.prompt(questions));
const configPath = path.join(this.cwd, this.result.configFilename);

if (installDevDeps === true) {
const packageManager = (await enquirer.prompt({
type: "select",
name: "packageManager",
message: "Which package manager do you want to use?",
initial: 0,
choices: ["npm", "yarn", "pnpm", "bun"]
})).packageManager;
if (executeInstallation === true) {

// removing `--force` when:
// 1. yarn v2+ -- it does not support it.
// 2. eslint v8.x -- it does not need it.
if (packageManager === "yarn" || this.answers.eslintVersion === "8.x") {
const index = this.result.installFlags.indexOf("--force");

if (index !== -1) {
this.result.installFlags.splice(index, 1);
}
}

log.info("☕️Installing...");
installSyncSaveDev(this.result.devDependencies, packageManager, this.result.installFlags);
Expand Down

0 comments on commit b377ad7

Please sign in to comment.