UNPKG

@bruxx/cli-tool

Version:

`BRX TEMPLATE` is a production-ready boilerplate for modern React projects. It eliminates the tedious setup process, letting you jump straight into coding with a preconfigured, optimized environment. Built with best practices, it’s designed for scalabilit

43 lines (34 loc) β€’ 1.17 kB
import { spawnSync } from "node:child_process"; import pc from "picocolors"; import which from "which"; export async function installDependencies(projectName, packageManager) { const installCommand = ["install"]; console.log( pc.blue( `Installing dependencies using ${packageManager} in ${projectName}...` ) ); const packageManagerPath = which.sync(packageManager, { nothrow: true }); if (!packageManagerPath) { console.error( pc.red(`Error: ${packageManager} is not installed or not in PATH.`) ); throw new Error("Failed to install dependencies."); } const result = spawnSync(packageManager, installCommand, { cwd: projectName, stdio: "inherit", }); const { status, error } = result; if (error) { console.error(pc.red(`Error: ${error.message}`)); throw new Error("Failed to install dependencies."); } if (status !== 0) { console.error( pc.red(`Failed to install dependencies. Exit code: ${status}`) ); throw new Error("Failed to install dependencies."); } console.log(pc.green("Dependencies installed successfully πŸŽ‰.")); }