create-hokage-js-app
Version:
🔥 Best CLI tool to create a MERN stack template. Quick, clean, and customizable.
22 lines (17 loc) • 597 B
JavaScript
import { exec } from 'child_process';
import util from 'util';
const execPromise = util.promisify(exec);
/**
* Runs a shell command in the specified directory.
* @param {string} cwd - The working directory.
* @param {string} command - The full command to run.
*/
export async function runCommand(cwd, command) {
try {
const { stdout, stderr } = await execPromise(command, { cwd });
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
} catch (err) {
throw new Error(`❌ Command failed: ${command}\n${err.stderr || err.message}`);
}
}