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

feat: add usePwsh helper for PowerShell v7+ #790

Merged
merged 7 commits into from
Apr 30, 2024

Conversation

ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Apr 29, 2024

Fixes #785

  • Tests pass
  • Appropriate changes to README are included in PR
  • Types updated

Notes

No documentation was added. I haven't found any documentation for other helpers apart from release notes...

A smoke test was added to win32 test but I'm not sure if it's a good idea.

  • pwsh is not available by default
  • pwsh can be used on any supported platform

So the last commit can be dropped. Or I can create a new smoke test.

Description

A new helper usePwsh to use pwsh shell (PowerShell v7+).

import { usePowerShell, usePwsh } from 'zx'

usePowerShell() // to enable powershell.exe (PowerShell v5 on Windows)
usePwsh()       // switch to pwsh (PowerShell v7 on any supported platform)

Usage

Tested on Windows 11 and Fedora 38

usePwsh()
console.log((await $`echo 'Foo' && echo 'Bar'`).stdout)
Foo
Bar
usePowerShell()
console.log((await $`echo 'Foo' && echo 'Bar'`).stdout)
At line:1 char:12
+ echo 'Foo' && echo 'Bar'; exit $LastExitCode
+            ~~
The token '&&' is not a valid statement separator in this version.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine

ShGKme added 2 commits April 29, 2024 18:27
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Copy link

google-cla bot commented Apr 29, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ShGKme ShGKme changed the title Feat/use pwsh feat: add usePwsh helper for PowerShell v7+ Apr 29, 2024
Signed-off-by: Grigorii K. Shartsev <[email protected]>
@antonmedv antonmedv requested a review from antongolub April 29, 2024 21:48
ShGKme added 3 commits April 30, 2024 11:08
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
@ShGKme
Copy link
Contributor Author

ShGKme commented Apr 30, 2024

Fixed smoke test to use which from build/vendors, made Test / smoke-win32-node16 (pull_request) green 🟢

Added useBash and removed unneeded import from unit tests (having import with globals).

Fixed formatting.

Signed-off-by: Grigorii K. Shartsev <[email protected]>
Copy link
Collaborator

@antongolub antongolub left a comment

Choose a reason for hiding this comment

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

lgtm

@antonmedv antonmedv merged commit 18e8e13 into google:main Apr 30, 2024
8 of 12 checks passed
@antongolub
Copy link
Collaborator

antongolub commented Apr 30, 2024

@ShGKme, thanks for the improvement.

Could you also verify the snapshot [email protected]?

@ShGKme
Copy link
Contributor Author

ShGKme commented Apr 30, 2024

Could you also verify the snapshot [email protected]?

✅ Verified

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.

Feature request: add usePwsh helper for PowerShell 7+
3 participants