refactor: replace execa w/ ezspawn#115
Merged
antfu merged 2 commits intoantfu-collective:mainfrom Apr 25, 2024
Merged
Conversation
antfu
reviewed
Apr 25, 2024
| @@ -1,5 +1,5 @@ | |||
| /* eslint-disable no-console */ | |||
| import { execa, execaCommand } from 'execa' | |||
| import { async as ezspawnAsync } from '@jsdevtools/ez-spawn' | |||
Member
There was a problem hiding this comment.
Suggested change
| import { async as ezspawnAsync } from '@jsdevtools/ez-spawn' | |
| import { async as execute } from '@jsdevtools/ez-spawn' |
A bit nitpicking, but how about just making the name easy by describing what it does than what it is made?
I don't even mind NTR it to be execa 🤣
Contributor
Author
There was a problem hiding this comment.
Since we only use the async method anyway, I am going to alias it to a simple name.
Just like how execa exports a named method execa, let's use ezspawn.
|
This cli tool do not need third-party package to execute command. Just use import childProcess from "node:child_process";
const config= JSON.parse(
childProcess.execSync(`echo '{"hello":"world"}'`).toString("utf8"),
);
console.log(config); // {hello: 'world'} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I first encountered the package
@jsdevtools/ez-spawnthroughbumpp, which usesexspawnunder the hood.Though no longer being actively maintained,
ezspawnalready fulfills almost every use case and doesn't suffer from breaking bugs.@jsdevtools/ez-spawnhas fewer dependencies thanexecaand takes up only 47% of the disk space (the installation size of@jsdevtools/ez-spawnis 142 KiB compared toexecaat 301 KiB). Moreover, its usage is extremely straightforward. Unlikeexeca, which has separatedexecaandexecCommand,ezspawn's single method can perform both functions.