UNPKG

@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

20 lines (19 loc) 785 B
import path from "@reliverse/pathkit"; import fs from "@reliverse/relifso"; import { exec } from "node:child_process"; export async function uninstallDependencies(cwd, dependencies) { if (dependencies.length === 0) { return; } const packageManager = await fs.pathExists(path.join(cwd, "yarn.lock")) ? "yarn" : await fs.pathExists(path.join(cwd, "pnpm-lock.yaml")) ? "pnpm" : "npm"; const uninstallCmd = packageManager === "npm" ? `npm uninstall ${dependencies.join(" ")}` : packageManager === "yarn" ? `yarn remove ${dependencies.join(" ")}` : `pnpm remove ${dependencies.join(" ")}`; await new Promise((resolve, reject) => { exec(uninstallCmd, { cwd }, (error) => { if (error) { reject(error); } else { resolve(); } }); }); }