Closed SukkaW closed 6 months ago
This cli tool do not need third-party package to execute command. Just use childProcess.execSync
is enough.
import childProcess from "node:child_process";
const config= JSON.parse(
childProcess.execSync(`echo '{"hello":"world"}'`).toString("utf8"),
);
console.log(config); // {hello: 'world'}
I first encountered the package
@jsdevtools/ez-spawn
throughbumpp
, which usesexspawn
under the hood.Though no longer being actively maintained,
ezspawn
already fulfills almost every use case and doesn't suffer from breaking bugs.@jsdevtools/ez-spawn
has fewer dependencies thanexeca
and takes up only 47% of the disk space (the installation size of@jsdevtools/ez-spawn
is 142 KiB compared toexeca
at 301 KiB). Moreover, its usage is extremely straightforward. Unlikeexeca
, which has separatedexeca
andexecCommand
,ezspawn
's single method can perform both functions.