Skip to content

fix(exec): revert script ordering change for pnpm run --sequential /regex/ - #13175

Merged
zkochan merged 1 commit into
pnpm:mainfrom
MattIPv4:MattIPv4/fix-sequential-script-order
Jul 23, 2026
Merged

zkochan merged 1 commit into
pnpm:mainfrom
MattIPv4:MattIPv4/fix-sequential-script-order

Conversation

@MattIPv4

@MattIPv4 MattIPv4 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reverts the lexicographical sorting of scripts introduced in #13074, as this was a breaking change in behaviour. When using pnpm run --sequential /regex/, scripts will now be executed in the order they are listed in package.json, giving developers control over the order without needing odd script prefixes. Fixes #13174.

I'm unfortunately not familiar enough with Rust to confidently port this to the new implementation (and didn't want to set an agent on it without being able to review what it did myself). This may be a case where the Rust version introduces a breaking change to this behaviour when released (though I would very much prefer to have it also match the package.json order so developers have more control).

Squash Commit Body

Reverts the lexicographical sorting of scripts introduced in pnpm/pnpm#13074, as this was a breaking change in behaviour. When using `pnpm run --sequential /regex/`, scripts will now be executed in the order they are listed in `package.json`, giving developers control over the order without needing odd script prefixes. Fixes pnpm/pnpm#13174.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Restored pnpm run --sequential RegExp-based script selection to execute in the same order scripts appear in package.json, rather than alphabetical order.
  • Tests
    • Updated RegExp --sequential coverage to assert the new execution order, including corresponding expected output changes.

@MattIPv4
MattIPv4 requested a review from zkochan as a code owner July 20, 2026 12:46
Copilot AI review requested due to automatic review settings July 20, 2026 12:46
@welcome

welcome Bot commented Jul 20, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b217e1a-3bd9-458e-945a-08a47d508705

📥 Commits

Reviewing files that changed from the base of the PR and between 2bfdf80 and 8b16905.

📒 Files selected for processing (3)
  • .changeset/some-games-smash.md
  • pnpm11/exec/commands/src/runRecursive.ts
  • pnpm11/exec/commands/test/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/some-games-smash.md
  • pnpm11/exec/commands/src/runRecursive.ts

📝 Walkthrough

Walkthrough

Regex-selected scripts used with pnpm run --sequential now execute in package.json order rather than lexicographic order. Tests reflect the new order, and a patch changeset records the correction.

Changes

Regex script ordering

Layer / File(s) Summary
Preserve package.json script order
pnpm11/exec/commands/src/runRecursive.ts, pnpm11/exec/commands/test/index.ts, .changeset/some-games-smash.md
Removes sorting from regex-selected scripts, updates the sequential execution assertion to package.json order, and adds patch releases for @pnpm/exec.commands and pnpm.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 13174 — Tracks the same sequential regex script-ordering regression.

Possibly related PRs

  • pnpm/pnpm#13074 — Changes the same script-selection behavior and related ordering tests.

Suggested labels: product: pnpm@11

Suggested reviewers: zkochan, copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is a one-line removal of a sort that was already flagged as a breaking regression, and the updated test covers the restored behaviour.

The change is a targeted revert of a single .sort() call with a matching test update. No logic was altered beyond restoring the previous insertion-order behaviour, and the changeset is complete.

No files require special attention.

Reviews (4): Last reviewed commit: "fix(exec): revert script ordering change..." | Re-trigger Greptile

Comment thread .changeset/some-games-smash.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reverts the regex-selected script execution ordering so pnpm run --sequential /regex/ runs matched scripts in package.json insertion order (instead of lexicographical order), restoring pre-pnpm/pnpm#13074 behavior in the TypeScript CLI.

Changes:

  • Removed .sort() from regex script selection (getSpecifiedScripts) so selection preserves package.json order.
  • Updated the test to assert package.json ordering (and adjusted expected log output).
  • Added a changeset for the behavior change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pnpm11/exec/commands/src/runRecursive.ts Stops sorting regex-matched script names, preserving package.json key order.
pnpm11/exec/commands/test/index.ts Updates the regression test to validate package.json ordering under --sequential.
.changeset/some-games-smash.md Adds a release note entry for the ordering revert (needs pnpm package included).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .changeset/some-games-smash.md Resolved
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 12:51
@MattIPv4
MattIPv4 force-pushed the MattIPv4/fix-sequential-script-order branch from 4247ce3 to a613ea2 Compare July 20, 2026 12:51
@kairosci

Copy link
Copy Markdown
Contributor

I don't think reverting is a good idea; we should implement validation that excludes the regex case. Besides, this should also be resolved in the pacquet, since at this point I doubt the same error even exists.

@MattIPv4

Copy link
Copy Markdown
Contributor Author

I don't think reverting is a good idea; we should implement validation that excludes the regex case.

@kairosci I'm not sure I understand what you're saying? This was a breaking change in behaviour introduced in a non-semver-major release, it needs to be reverted? I have updated the test case to match the behaviour prior to the change you made.

Besides, this should also be resolved in the pacquet, since at this point I doubt the same error even exists.

Yes, I have called that out in the description that this likely needs to also be addressed in the Rust implementation, though that is beyond my knowledge.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 20, 2026 12:58
@MattIPv4
MattIPv4 force-pushed the MattIPv4/fix-sequential-script-order branch from a613ea2 to 2bfdf80 Compare July 20, 2026 12:58
@kairosci

Copy link
Copy Markdown
Contributor

I understand your point, but since it's going to be fixed anyway, we might as well fix it directly without rolling it back.

Moreover ci fails.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread pnpm11/exec/commands/test/index.ts Resolved
@MattIPv4

MattIPv4 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor Author

I understand your point, but since it's going to be fixed anyway, we might as well fix it directly without rolling it back.

I'm still not sure I understand. This PR is fixing it directly? The fix is to revert the behavior to how it was before?

Moreover ci fails.

Should be fixed now 👍 I would appreciate you helping by suggesting changes rather than just repeatedly telling me how this fix to a breaking change you made is wrong.

Copilot AI review requested due to automatic review settings July 20, 2026 13:07
@MattIPv4
MattIPv4 force-pushed the MattIPv4/fix-sequential-script-order branch from 2bfdf80 to 8b16905 Compare July 20, 2026 13:07
@MattIPv4

Copy link
Copy Markdown
Contributor Author

rollback isn't solution for me, for others idk.

Okay... what is a solution to you then? How do you intend to restore the behaviour that the package had before without restoring that behaviour? That sentence alone makes no sense.

Again, could I ask that you actually try to help here instead of just pointing out in vague terms how you think this PR is wrong?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@kairosci

Copy link
Copy Markdown
Contributor

Sorry for rushed and superficial messages.
As I was saying; both orderings need to be supported: package.json insertion order when --sequential is used, and alphabetical for deterministic parallelism. That's exactly why a rollback isn't a good idea, it would lose the deterministic alphabetical sort that parallel mode needs.

I've taken care of it in #13199 by adding a sort parameter to getSpecifiedScripts / specified_scripts: non-sequential runs sort alphabetically for deterministic parallelism, while --sequential preserves package.json insertion order. Same approach landed in the Rust pacquet port with /regexp/ selector support for parity.

@MattIPv4

Copy link
Copy Markdown
Contributor Author

Ah okay, that makes more sense, though isn't the ordering from package.json also deterministic (I'm not sure I follow why parallel runs need different sorting)?

Thanks for getting that PR up though to ensure the Rust implementation is equivalent, hopefully that lands soon to fix this and unblock us updating our pnpm usage 🙏

@kairosci

Copy link
Copy Markdown
Contributor

That’s a valid question; the order in package.json is deterministic, but it depends on the developer’s choice and can change from commit to commit.

The point is something else: in parallel mode, the user does not control the order in which child processes complete (the output is interleaved), so an arbitrary but stable order (alphabetical) makes the behavior predictable and comparable across CI runs, machines, and branches; regardless of how someone reorganizes the scripts in package.json.

With --sequential, on the other hand, the user wants to control the execution order, so it makes sense to respect the order in which items are listed in package.json (it’s the explicit interface for sequential execution).

@zkochan

zkochan commented Jul 23, 2026

Copy link
Copy Markdown
Member

The breaking change should be reverted. Sorry for not noticing this in the original PR.

@zkochan
zkochan merged commit a4f25f2 into pnpm:main Jul 23, 2026
27 checks passed
@welcome

welcome Bot commented Jul 23, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm run --sequential /regex/ order changed

4 participants