Skip to content
New issue

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

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

Already on GitHub? # to your account

Add h2 shortcut with shell aliases #679

Merged
merged 13 commits into from
Apr 3, 2023
Merged

Add h2 shortcut with shell aliases #679

merged 13 commits into from
Apr 3, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Mar 13, 2023

Like #430 but only creating aliases at the shell level. Something similar to alias h2='$(npm bin)/shopify hydrogen' in ZSH/Bash.

🎩 :

  • cd templates/hello-world
  • npx shopify hydrogen shortcut <-- creates the shell h2 alias
  • h2 g r cart

Notes:

  • I couldn't make static aliases work in Oclif. No idea why, it just ignores them.

Copy link
Contributor

@cartogram cartogram left a comment

Choose a reason for hiding this comment

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

Testing locally worked (Mac only)! The code here is still a bit confusing to me because I don't have a lot of knowledge about shell/OS stuff, but the code is easy enough to follow. I think this strikes a better balance for this feature wrt longer-term support. Do you mind adding some tests as well? Enough to mock each platform and assert that the various branches do what they should.

🚀 🚀 Thanks for continuing to push this forward!

@frandiox frandiox marked this pull request as ready for review March 15, 2023 09:45
@github-actions

This comment has been minimized.

@frandiox frandiox requested a review from a team March 15, 2023 09:48
@benjaminsehl
Copy link
Member

🎉🎉

Copy link
Contributor

@cartogram cartogram left a comment

Choose a reason for hiding this comment

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

🚀🚀🚀

}

// Create a PowerShell function and an alias to call it.
const PS_FUNCTION = `function Invoke-Local-H2 {$npmPrefix = npm prefix -s; Invoke-Expression "$npmPrefix\\node_modules\\.bin\\shopify.ps1 hydrogen $Args"}; Set-Alias -Name ${ALIAS_NAME} -Value Invoke-Local-H2`;
Copy link
Contributor

Choose a reason for hiding this comment

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

You are a powershell ninja

@frandiox frandiox merged commit 68a6028 into 2023-01 Apr 3, 2023
@frandiox frandiox deleted the fd-h2-shell-alias branch April 3, 2023 11:01
@github-actions github-actions bot mentioned this pull request Apr 3, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants