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

fix: correctly copy to clipboard in astro info #12641

Merged
merged 6 commits into from
Dec 5, 2024
Merged

fix: correctly copy to clipboard in astro info #12641

merged 6 commits into from
Dec 5, 2024

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Dec 5, 2024

Changes

astro info copy to clipboard has not been working on Mac because piping the input to pbcopy using execSync seems to not work. This PR fixes that by switching to spawnSync instead of execSync. It also adds a helper to read from the clipboard so we can check it works across platforms, and adds support for a --copy flag to avoid needing to prompt.

Fixes #12639

Testing

Adds a new test suite.

Docs

Copy link

changeset-bot bot commented Dec 5, 2024

🦋 Changeset detected

Latest commit: 8063bee

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Dec 5, 2024
Copy link

codspeed-hq bot commented Dec 5, 2024

CodSpeed Performance Report

Merging #12641 will not alter performance

Comparing clipboard-fix (8063bee) with main (22e405a)

Summary

✅ 4 untouched benchmarks

@ascorbic ascorbic marked this pull request as ready for review December 5, 2024 11:47
@ascorbic ascorbic changed the title fix: correctly copy to clipboard on mac fix: correctly copy to clipboard in astro info Dec 5, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Looks good! Left some feedback. I didn't test the code myself

throw result.error;
}
console.log(colors.green('Copied to clipboard!'));
} catch (err) {
Copy link
Member

Choose a reason for hiding this comment

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

Unused (thank you github annotations)

if (!shouldCopy) return;
if (!command) {
console.error(colors.red('\nClipboard command not found!'));
console.log('Please manually copy the text above.');
Copy link
Member

Choose a reason for hiding this comment

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

Use .info instead. Usually .log is more for debugging

if (result.error) {
throw result.error;
}
console.log(colors.green('Copied to clipboard!'));
Copy link
Member

Choose a reason for hiding this comment

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

Use .info

.changeset/angry-pumas-act.md Outdated Show resolved Hide resolved
@ascorbic ascorbic merged commit 48ca399 into main Dec 5, 2024
16 checks passed
@ascorbic ascorbic deleted the clipboard-fix branch December 5, 2024 13:01
@astrobot-houston astrobot-houston mentioned this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy to clipboard doesn't work
2 participants