Skip to content

Commit

Permalink
refactor: logic suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
  • Loading branch information
snitin315 and sokra committed Nov 20, 2020
1 parent e827f4f commit fa7686c
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,17 @@ if (!cli.installed) {

console.error(notify);

const isNpm = fs.existsSync(path.resolve(process.cwd(), "package-lock.json"));

let isYarn = false;

if (!isNpm) {
isYarn = fs.existsSync(path.resolve(process.cwd(), "yarn.lock"));
}

let isPnpm = false;

if (!isYarn) {
isPnpm = fs.existsSync(path.resolve(process.cwd(), "pnpm-lock.yaml"));
}

let packageManager;

if (isYarn) {
if (fs.existsSync(path.resolve(process.cwd(), "yarn.lock"))) {
packageManager = "yarn";
} else if (isPnpm) {
} else if (fs.existsSync(path.resolve(process.cwd(), "pnpm-lock.yaml"))) {
packageManager = "pnpm";
} else {
packageManager = "npm";
}

const installOptions = [isYarn ? "add" : "install", "-D"];
const installOptions = [packageManager === "yarn" ? "add" : "install", "-D"];

console.error(
`We will use "${packageManager}" to install the CLI via "${packageManager} ${installOptions.join(
Expand Down

0 comments on commit fa7686c

Please sign in to comment.