-
-
Save mayank99/de57c5b2bd1ef4425374c20547d27f81 to your computer and use it in GitHub Desktop.
make your own `execa`-like shell with node built-ins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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