npm / npm/rfcs

[FEATURE] run-script with workspaces should short-circuit on script error

Open
#575 23 comments 46 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Release 8.x
Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

run-script with the --workspaces flag will run all workspace scripts, regardless if one script exits with exit code 1. Please see the "Steps to Reproduce" section.

Expected Behavior

I would expect that run-script would short-circuit and not run the other scripts if one fails. Alternatively, a new flag (e.g. --short-circuit) could be introduced to run-script in order to maintain backwards compatibility.

Steps To Reproduce

Consider the following scenario:

  • A root package.json file has "workspaces": ["a", "b", "c"]
  • a/package.json has the script "build": "exit 1"
  • Both b/package.json and c/package.json have the the script "build": "exit 0"

Run npm run build --workspaces and note that all scripts are run.

Environment
  • OS: Windows 10
  • Node: 16.10.0
  • npm: 7.24.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reproducing the described workspace setup with npm run build --workspaces, then read the npm CLI run-script workspace behavior and the comment discussion to resolve whether short-circuiting or a new flag is intended. Done means the chosen behavior is specified and verified for both failing and successful workspace scripts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.