@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
35 lines (34 loc) • 799 B
JavaScript
import { exec } from "child_process";
export function installDependencies({
dependencies,
packageManager,
cwd
}) {
let installCommand;
switch (packageManager) {
case "npm":
installCommand = "npm install --force";
break;
case "pnpm":
installCommand = "pnpm install";
break;
case "bun":
installCommand = "bun install";
break;
case "yarn":
installCommand = "yarn install";
break;
default:
throw new Error("Invalid package manager");
}
const command = `${installCommand} ${dependencies.join(" ")}`;
return new Promise((resolve, reject) => {
exec(command, { cwd }, (error, _stdout, stderr) => {
if (error) {
reject(new Error(stderr));
return;
}
resolve(true);
});
});
}