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

chore(deps): replace execa with tinyexec #6454

Merged
merged 15 commits into from
Sep 6, 2024
Merged

chore(deps): replace execa with tinyexec #6454

merged 15 commits into from
Sep 6, 2024

Conversation

ziebam
Copy link
Contributor

@ziebam ziebam commented Sep 5, 2024

Description

This PR replaces execa with a lighter tinyexec as discussed here: #5713. Some notes inline as a code review, please let me know whether it'd make sense to comment the code accordingly in those places.

Not sure how to handle the third item in the checklist – should I revert the changes that remove the execa dependency?

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Sep 5, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2ce84a9
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/66da1612fdf378000809a69b
😎 Deploy Preview https://deploy-preview-6454--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Sep 5, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9aebdc4
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/66da1649a3517d00089e5d8d
😎 Deploy Preview https://deploy-preview-6454--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines -502 to +505
await execa(command, allArgs, {
stdout: 'inherit',
stderr: 'inherit',
await x(command, allArgs, {
nodeOptions: {
stdio: ['pipe', 'inherit', 'inherit'],
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tinyexec doesn't provide a wrapper that passes the options along to stdio, so we pass them directly. pipe is used for stdin (first item in the array) as it was the default in execa: https://github.com/sindresorhus/execa/blob/HEAD/docs/api.md#optionsstdin.

return resolve(cwd, result.stdout)
return resolve(cwd, result.stdout.trim())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

execa trims the leading newline by default, while tinyexec doesn't. Without trimming, we'd try to launch git with invalid cwd (due to the leading newline) which broke the functionality.

cwd: root,
stdio: 'pipe',
},
throwOnError: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I've investigated in both execa and tinyexec, this should be roughly equivalent to reject: false. Relevant PR: tinylibs/tinyexec#34.

const child = x(typecheck.checker, args, {
nodeOptions: {
cwd: root,
stdio: 'pipe',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

stdio: 'pipe' is equivalent to stdio: ['pipe', 'pipe', 'pipe'] which is the default in execa.

@ziebam ziebam changed the title chore(deps): Replace execa with tinyexec chore(deps): replace execa with tinyexec Sep 5, 2024
@sheremet-va
Copy link
Member

Not sure how to handle the third item in the checklist – should I revert the changes that remove the execa dependency?

That's just so you don't publish a random lockfile. If you update dependency, it's ok to update the lockfile.

@sheremet-va sheremet-va merged commit 0282564 into vitest-dev:main Sep 6, 2024
5 checks passed
@sheremet-va
Copy link
Member

Thank you!

@ziebam ziebam deleted the execa-to-tinyexec branch September 6, 2024 11:51
sheremet-va added a commit that referenced this pull request Sep 12, 2024
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.

2 participants