Execute shell commands with enhanced alternatives to exec() and spawn(), offering a cleaner API, promise support, and optional fun mode.
GitHub: https://github.com/hrach347/exec-cute
npm install exec-cuteimport { run } from "exec-cute";
const { stdout, stderr, err } = await run("ls -la");
console.log("Output:", stdout);- Promise-based API - no callbacks or nested logic
- Consistent return object - always returns { stdout, stderr, err }
- Controlled error handling - errors don’t crash your flow, you handle them manually
- Optional wait delay - delay execution before running the command
import { spawnProcess } from "exec-cute";
const child = spawnProcess("ping 1.1.1.1");
child.onData((data, stdout, stderr) => {
if (stdout) console.log("stdout:", data);
if (stderr) console.error("stderr:", data);
});- Cleaner API - run a full command string instead of splitting command and args manually
- Single output handler - onData() receives stdout and stderr in one place
- Less boilerplate - no need to manually attach child.stdout.on() and child.stderr.on()
- Faster to write - fewer lines needed to get real-time command output
- Readable code - command execution stays simple and easy to understand
- Safer defaults - avoids common mistakes when working with spawn streams
- Automatic Buffer handling - stdout/stderr Buffers are automatically converted to strings
// creating a file
import { run, funMode } from "exec-cute";
funMode(true);
const { stdout } = await run("touch newFile.txt");
// ╔═ exec-cute ════════════════════════════════════════════════════════════════╗
// ✍️ Running: "touch newFile.txt" ✍️
// ╚════════════════════════════════════════════════════════════════════════════╝
// ✅ SUCCESS ✅
// removing a file
import { run, funMode } from "exec-cute";
funMode(true);
const { stdout } = await run("rm newFile.txt");
// ╔═ exec-cute ════════════════════════════════════════════════════════════════╗
// 🔥 Running: "rm newFile.txt" 🔥
// ╚════════════════════════════════════════════════════════════════════════════╝
// ✅ SUCCESS ✅
funMode(true) // Enable
funMode(false) // DisableExec-cute makes Node.js shell commands cleaner, safer, and more reliable, while keeping the experience enjoyable with optional fun mode features like emojis, colored output, and banners. It still gives you full control over stdout, stderr, errors, and streaming data.
import { run } from "exec-cute";
// Run with delay
const { stdout: delayed } = await run("echo Delayed Command", { wait: 1000 });
console.log("Delayed output:", delayed);
// Handling errors without crashing
const { stdout, stderr, err } = await run("ls /nonexistent");
if (err) console.log("Caught error:", stderr);
// Chaining commands manually
const { stdout: first } = await run("echo First");
const { stdout: second } = await run(`echo Second after "${first.trim()}"`);
console.log(first.trim(), "->", second.trim());import { spawnProcess } from "exec-cute";
// Real-time streaming of a long-running command
const child = spawnProcess("ping -c 4 1.1.1.1");
child.onData((data, stdout, stderr) => {
if (stdout) console.log("Live output:", data);
if (stderr) console.error("Error output:", data);
});
// Run multiple commands at once
const listChild = spawnProcess("ls -la");
listChild.onData((data) => console.log("Listing:", data));
const dateChild = spawnProcess("date");
dateChild.onData((data) => console.log("Current time:", data));- MIT
Exec-cute makes running Node.js shell commands clean, reliable, and fun. Enjoy !