Skip to content

Instantly share code, notes, and snippets.

@mayank99
Last active May 6, 2024 10:44
Show Gist options
  • Save mayank99/de57c5b2bd1ef4425374c20547d27f81 to your computer and use it in GitHub Desktop.
Save mayank99/de57c5b2bd1ef4425374c20547d27f81 to your computer and use it in GitHub Desktop.
make your own `execa`-like shell with node built-ins
import { promisify } from 'node:util';
import { exec } from 'node:child_process';
const $ = async (strings, ...values) => {
try {
return (await promisify(exec)(String.raw({ raw: strings }, ...values))).stdout;
} catch {
return ''; // yolo
}
};
// console.log(await $`echo hello`);
// console.log(await $`git status`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment