Skip to content

feat(core): allow {args} to be fully interpolated in run-commands #31824

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

Merged
merged 2 commits into from
Jul 15, 2025

Conversation

Coly010
Copy link
Contributor

@Coly010 Coly010 commented Jul 3, 2025

Current Behavior

Currently, there is no way for a target using run-commands to define where in the command args are attached.
This is problematic in some tooling cases where args positional location matters

Expected Behavior

Placing {args} into the command should allow for interpolation of any and all args provided.
Therefore commands can be written such as docker run {args} imageRef

@Coly010 Coly010 requested a review from a team as a code owner July 3, 2025 11:45
@Coly010 Coly010 self-assigned this Jul 3, 2025
@Coly010 Coly010 requested a review from Cammisuli July 3, 2025 11:45
Copy link

vercel bot commented Jul 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Jul 4, 2025 3:40pm

Copy link
Contributor

nx-cloud bot commented Jul 3, 2025

View your CI Pipeline Execution ↗ for commit 4a36a9c

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 40m 7s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 15s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 6s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 4s View ↗
nx documentation ✅ Succeeded 1m 21s View ↗

☁️ Nx Cloud last updated this comment at 2025-07-04 16:11:54 UTC

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds full {args} interpolation support to the run-commands executor, refactors the existing argument-forwarding logic into helper functions, and updates tests to cover the new behavior.

  • Introduce a {args} placeholder branch in interpolateArgsIntoCommand
  • Extract argument-building logic into unknownOptionsToArgsArray and unparsedOptionsToArgsArray
  • Refactor readFile in tests and add a test for {args} interpolation

Reviewed Changes

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

File Description
packages/nx/src/executors/run-commands/run-commands.impl.ts Add {args} interpolation, refactor forwardAllArgs logic, and introduce two helper functions
packages/nx/src/executors/run-commands/run-commands.impl.spec.ts Extend readFile helper and add a new test case verifying {args} interpolation
Comments suppressed due to low confidence (1)

packages/nx/src/executors/run-commands/run-commands.impl.spec.ts:231

  • The new test covers interpolation of __unparsed__ args, but doesn’t verify behavior when opts.args is also provided. Adding a test that includes both __unparsed__ and args would ensure full coverage of the {args} branch.
  it('should interpolate {args} to contain all provided args', async () => {

@FrozenPandaz FrozenPandaz merged commit 434cf45 into master Jul 15, 2025
8 checks passed
@FrozenPandaz FrozenPandaz deleted the interpolate-args branch July 15, 2025 15:11
ndcunningham pushed a commit that referenced this pull request Jul 15, 2025
…1824)

## Current Behavior
Currently, there is no way for a target using `run-commands` to define
where in the command args are attached.
This is problematic in some tooling cases where args positional location
matters

## Expected Behavior
Placing `{args}` into the command should allow for interpolation of any
and all args provided.
Therefore commands can be written such as `docker run {args} imageRef`
FrozenPandaz pushed a commit that referenced this pull request Jul 15, 2025
…1824)

## Current Behavior
Currently, there is no way for a target using `run-commands` to define
where in the command args are attached.
This is problematic in some tooling cases where args positional location
matters

## Expected Behavior
Placing `{args}` into the command should allow for interpolation of any
and all args provided.
Therefore commands can be written such as `docker run {args} imageRef`

(cherry picked from commit 434cf45)
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants