Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace execa w/ ezspawn #115

Merged
merged 2 commits into from
Apr 25, 2024
Merged

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Apr 25, 2024

I first encountered the package @jsdevtools/ez-spawn through bumpp, which uses exspawn 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 than execa and takes up only 47% of the disk space (the installation size of @jsdevtools/ez-spawn is 142 KiB compared to execa at 301 KiB). Moreover, its usage is extremely straightforward. Unlike execa, which has separated execa and execCommand, ezspawn's single method can perform both functions.

@@ -1,5 +1,5 @@
/* eslint-disable no-console */
import { execa, execaCommand } from 'execa'
import { async as ezspawnAsync } from '@jsdevtools/ez-spawn'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤣

Copy link
Contributor Author

@SukkaW SukkaW Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@antfu antfu merged commit 5c7aa67 into antfu-collective:main Apr 25, 2024
5 checks passed
@zanminkian
Copy link

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'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants