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

prepublishOnly script does not extrapolate env variables #8414

Open
2 of 4 tasks
iki opened this issue Aug 13, 2024 · 0 comments
Open
2 of 4 tasks

prepublishOnly script does not extrapolate env variables #8414

iki opened this issue Aug 13, 2024 · 0 comments

Comments

@iki
Copy link

iki commented Aug 13, 2024

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Use the following scripts in package.json:
{
    "prepublishOnly": "[ -n \"$TURBO_HASH\" ] && echo Check and build did already run as dependencies of turborepo task [$TURBO_HASH] || turbo publish:check check build",
    "publish:check": "[ `pnpm config -g get @pcr:registry` != 'undefined' ] || ! echo 'Error: Missing required @pcr:registry in ~/.npmrc'",
}
  1. Run pnpm publish --no-git-checks

Expected result: Turbo tasks run before publish
Actual result: Outputs Check and build did already run as dependencies of turborepo task [$TURBO_HASH] literally, without extrapolated $TURBO_HASH

  1. Workaround: Change the scripts in package.json:
{
    "prepublishOnly": "pnpm publish:init",
    "publish:init": "[ -n \"$TURBO_HASH\" ] && echo Check and build did already run as dependencies of turborepo task [$TURBO_HASH] || turbo publish:check check build",
    "publish:check": "[ `pnpm config -g get @pcr:registry` != 'undefined' ] || ! echo 'Error: Missing required @pcr:registry in ~/.npmrc'",
}
  1. Run pnpm publish --no-git-checks

Result (correct): Turbo tasks run before publish

Describe the Bug

Apparently prepublishOnly script does not extrapolate env variables in step 2 above.

The workaround is to crate another script and run it from prepublishOnly like in step 3 above.

Expected Behavior

The prepublishOnly script should extrapolate env variables and steps 1 and 2 above should work as expected.

Which Node.js version are you using?

22.5.1

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@iki iki added the type: bug label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant