Skip to content

Commit f473db5

Browse files
chore: choose default installer based on the lock file presence
1 parent ed5828d commit f473db5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/generators/src/init-generator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ export default class InitGenerator extends CustomGenerator {
100100
}
101101

102102
public async installPlugins(): Promise<void> {
103+
// Prompt for the package manager of choice
104+
const defaultPackager = this.utils.getPackageManager();
103105
const { packager } = await Question.List(
104106
this,
105107
"packager",
106108
"Pick a package manager:",
107109
this.utils.getAvailableInstallers(),
108-
"npm",
110+
defaultPackager,
109111
false,
110112
);
111113
const opts: {

packages/webpack-cli/lib/utils/get-available-installers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { sync } = require("execa");
22

33
const utils = require("./");
44

5-
function isPmInstalled(packageManager) {
5+
function hasPmInstalled(packageManager) {
66
try {
77
sync(packageManager, ["--version"]);
88
return packageManager;
@@ -13,7 +13,7 @@ function isPmInstalled(packageManager) {
1313

1414
function getAvailableInstallers() {
1515
const installers = ["npm", "yarn", "pnpm"];
16-
const availableInstallers = installers.filter((installer) => isPmInstalled(installer));
16+
const availableInstallers = installers.filter((installer) => hasPmInstalled(installer));
1717

1818
if (!availableInstallers.length) {
1919
utils.logger.error("No package manager found.");

0 commit comments

Comments
 (0)