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

[BUG] workspaces infinite loop when running child scripts #5722

Closed
2 tasks done
ianstormtaylor opened this issue Oct 19, 2022 · 1 comment
Closed
2 tasks done

[BUG] workspaces infinite loop when running child scripts #5722

ianstormtaylor opened this issue Oct 19, 2022 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@ianstormtaylor
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

With workspaces, if you try to run all child scripts of name via a root script of the same name that uses the dotenv CLI, it will go into an infinite loop.

For example, in root:

{
  "name": "infinte-loop-example",
  "version": "0.0.0",
  "workspaces": ["a", "b"]
  "scripts": {
    "build": "dotenv npm run build --workspaces"
  }
}

And assuming a and b both define their own build scripts... If you run npm run build, you'll get an infinite loop:

$ npm run build

> [email protected] build
> dotenv npm run build --workspaces

> [email protected] build
> dotenv npm run build --workspaces

> [email protected] build
> dotenv npm run build --workspaces

> [email protected] build
> dotenv npm run build --workspaces

Expected Behavior

No infinite loop, and the a and b workspace build script is run.

Steps To Reproduce

See above.

Environment

  • npm: 8.19.2
  • Node.js: 18.11.0
  • OS Name: macOS
@ianstormtaylor ianstormtaylor added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Oct 19, 2022
@ianstormtaylor ianstormtaylor changed the title [BUG] <title> [BUG] workspaces infinite loop when running child scripts Oct 19, 2022
@ianstormtaylor
Copy link
Author

I tracked this down to dotenv needing a -- after it or else it swallows all the filters to subcommands. So for anyone else running into this, you need to do:

{
  "name": "infinte-loop-example",
  "version": "0.0.0",
  "workspaces": ["a", "b"]
  "scripts": {
    "build": "dotenv -- npm run build --workspaces"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

1 participant