Skip to content

Commit

Permalink
[config-inferrer] Use 'pnpm' package manager when there is a pnpm-loc…
Browse files Browse the repository at this point in the history
…k.yaml file or the package.json specifies it

Co-authored-by: Jiawen Geng <[email protected]>
  • Loading branch information
jankeromnes and gengjiawen committed Jul 25, 2022
1 parent 826a0bd commit 4fa28da
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions components/server/src/config/config-inferrer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,33 @@ export class ConfigInferrer {
if (!pckjsonContent) {
return;
}
let command: "yarn" | "npm" = "npm";
let pckjson;
try {
pckjson = JSON.parse(pckjsonContent);
} catch (e) {
console.log(e, pckjsonContent);
}
let command: "yarn" | "npm" | "pnpm" = "npm";
if (await ctx.exists("yarn.lock")) {
command = "yarn";
}
if ((await ctx.exists("pnpm-lock.yaml")) || pckjson?.packageManager?.startsWith("pnpm")) {
command = "pnpm";
}
this.addCommand(ctx.config, command + " install", "init");
try {
const pckjson = JSON.parse(pckjsonContent);
if (pckjson.scripts) {
if (pckjson.scripts.build) {
this.addCommand(ctx.config, command + " run build", "init");
} else if (pckjson.scripts.compile) {
this.addCommand(ctx.config, command + " run compile", "init");
}
if (pckjson.scripts.start) {
this.addCommand(ctx.config, command + " run start", "command");
} else if (pckjson.scripts.dev) {
this.addCommand(ctx.config, command + " run dev", "command");
} else if (pckjson.scripts.watch) {
this.addCommand(ctx.config, command + " run watch", "command");
}
if (pckjson.scripts) {
if (pckjson.scripts.build) {
this.addCommand(ctx.config, command + " run build", "init");
} else if (pckjson.scripts.compile) {
this.addCommand(ctx.config, command + " run compile", "init");
}
if (pckjson.scripts.start) {
this.addCommand(ctx.config, command + " run start", "command");
} else if (pckjson.scripts.dev) {
this.addCommand(ctx.config, command + " run dev", "command");
} else if (pckjson.scripts.watch) {
this.addCommand(ctx.config, command + " run watch", "command");
}
} catch (e) {
console.log(e, pckjsonContent);
}
this.addExtension(ctx, "dbaeumer.vscode-eslint");
}
Expand Down

0 comments on commit 4fa28da

Please sign in to comment.