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

docs: fix example for within function #625

Merged
merged 1 commit into from
May 19, 2023

Conversation

mdrobny
Copy link
Contributor

@mdrobny mdrobny commented May 19, 2023

I struggled with switching Node.js version via nvm in my zx script because docs are misleading currently - nvm use 16 must be part of prefix to allow using Node.js 16 inside the context

I found fix was provided in #362 but docs are incorrect

  • Appropriate changes to README are included in PR

Example

Current version

await $`node --version`

let version = await within(async () => {
    $.prefix += 'export NVM_DIR=$HOME/.nvm; source $NVM_DIR/nvm.sh;'

    await $`nvm use 16`

    return $`node --version`
})

echo(version);
$ node --version
v20.2.0
$ nvm use 16 <--- switching to version 16
Now using node v16.20.0 (npm v8.19.4)
$ node --version
v20.2.0 <---- but still 20 is used
v20.2.0

Fixed version

await $`node --version`

let version = await within(async () => {
    $.prefix += 'export NVM_DIR=$HOME/.nvm; source $NVM_DIR/nvm.sh; nvm use 16;'

    return $`node --version`
})

echo(version);
$ node --version
v20.2.0
$ node --version
Now using node v16.20.0 (npm v8.19.4)
v16.20.0 <---- it's actually 16 here
Now using node v16.20.0 (npm v8.19.4)
v16.20.0

- because `nvm use 16` must be part of prefix to allow using Node.js 16 inside the context
@google-cla
Copy link

google-cla bot commented May 19, 2023

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.

@antonmedv antonmedv merged commit d9f8a75 into google:main May 19, 2023
@antonmedv
Copy link
Collaborator

Thanks!

@mdrobny mdrobny deleted the docs/fix-within-example branch May 29, 2023 20:51
sebald referenced this pull request in sebald/pattern-analyzer Jul 14, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [zx](https://togithub.com/google/zx) | [`7.2.2` ->
`7.2.3`](https://renovatebot.com/diffs/npm/zx/7.2.2/7.2.3) |
[![age](https://badges.renovateapi.com/packages/npm/zx/7.2.3/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/zx/7.2.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/zx/7.2.3/compatibility-slim/7.2.2)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/zx/7.2.3/confidence-slim/7.2.2)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>google/zx (zx)</summary>

### [`v7.2.3`](https://togithub.com/google/zx/releases/tag/7.2.3)

[Compare Source](https://togithub.com/google/zx/compare/7.2.2...7.2.3)

#### What's Changed

- docs: fix example for within function by
[@&#8203;mdrobny](https://togithub.com/mdrobny) in
[https://github.com/google/zx/pull/625](https://togithub.com/google/zx/pull/625)
- enhance: cd to accept ProcessOutput by
[@&#8203;quexxon](https://togithub.com/quexxon) in
[https://github.com/google/zx/pull/642](https://togithub.com/google/zx/pull/642)

#### New Contributors

- [@&#8203;mdrobny](https://togithub.com/mdrobny) made their first
contribution in
[https://github.com/google/zx/pull/625](https://togithub.com/google/zx/pull/625)
- [@&#8203;quexxon](https://togithub.com/quexxon) made their first
contribution in
[https://github.com/google/zx/pull/642](https://togithub.com/google/zx/pull/642)

**Full Changelog**: google/zx@7.2.2...7.2.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/sebald/pattern-analyzer).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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