Skip to content

feat: add usePwsh helper for PowerShell v7+ - #790

Merged
antonmedv merged 7 commits into
google:mainfrom
ShGKme:feat/usePwsh
Apr 30, 2024
Merged

feat: add usePwsh helper for PowerShell v7+#790
antonmedv merged 7 commits into
google:mainfrom
ShGKme:feat/usePwsh

Conversation

@ShGKme

@ShGKme ShGKme commented Apr 29, 2024

Copy link
Copy Markdown
Contributor

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 <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@google-cla

google-cla Bot commented Apr 29, 2024

Copy link
Copy Markdown

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
Comment thread test/smoke/win32.test.js
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@antonmedv
antonmedv requested a review from antongolub April 29, 2024 21:48
Comment thread test/core.test.js
ShGKme added 3 commits April 30, 2024 11:08
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@ShGKme

ShGKme commented Apr 30, 2024

Copy link
Copy Markdown
Contributor Author

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.

Comment thread test/smoke/win32.test.js Outdated
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>

@antongolub antongolub left a comment

Copy link
Copy Markdown
Collaborator

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
@antongolub

antongolub commented Apr 30, 2024

Copy link
Copy Markdown
Collaborator

@ShGKme, thanks for the improvement.

Could you also verify the snapshot zx@8.0.2-dev.bc2a08c?

@ShGKme

ShGKme commented Apr 30, 2024

Copy link
Copy Markdown
Contributor Author

Could you also verify the snapshot zx@8.0.2-dev.bc2a08c?

✅ 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