diff --git a/internal/run/run.go b/internal/run/run.go index 3197e5d93f96c..80ce0668e5652 100644 --- a/internal/run/run.go +++ b/internal/run/run.go @@ -417,13 +417,15 @@ func (c *RunCommand) Run(args []string) int { pipeline = altpipe } hashable := struct { - Hash string - Task string - Outputs []string + Hash string + Task string + Outputs []string + PassThruArgs []string }{ - Hash: pack.Hash, - Task: task, - Outputs: pipeline.Outputs, + Hash: pack.Hash, + Task: task, + Outputs: pipeline.Outputs, + PassThruArgs: runOptions.passThroughArgs, } hash, err := fs.HashObject(hashable) targetLogger.Debug("task hash", "value", hash) @@ -478,6 +480,7 @@ func (c *RunCommand) Run(args []string) int { targetUi.Output(fmt.Sprintf("cache miss, executing %s", ui.Dim(hash))) } argsactual := append([]string{"run"}, task) + argsactual = append(argsactual, runOptions.passThroughArgs...) // @TODO: @jaredpalmer fix this hack to get the package manager's name cmd := exec.Command(strings.TrimPrefix(ctx.Backend.Name, "nodejs-"), argsactual...) cmd.Dir = pack.Dir @@ -687,21 +690,23 @@ type RunOptions struct { // Cache folder cacheFolder string // Immediately exit on task failure - bail bool + bail bool + passThroughArgs []string } func getDefaultRunOptions() *RunOptions { return &RunOptions{ - bail: true, - deps: true, - parallel: false, - concurrency: 10, - dotGraph: "", - ancestors: false, - cache: true, - profile: "", // empty string does no tracing - forceExecution: false, - stream: true, + bail: true, + deps: true, + parallel: false, + concurrency: 10, + dotGraph: "", + ancestors: false, + cache: true, + profile: "", // empty string does no tracing + forceExecution: false, + stream: true, + passThroughArgs: []string{}, } } @@ -714,8 +719,11 @@ func parseRunArgs(args []string, cwd string) (*RunOptions, error) { unresolvedCacheFolder := "./node_modules/.cache/turbo" - for _, arg := range args { - if strings.HasPrefix(arg, "--") { + for argIndex, arg := range args { + if arg == "--" { + runOptions.passThroughArgs = args[argIndex+1:] + break + } else if strings.HasPrefix(arg, "--") { switch { case strings.HasPrefix(arg, "--since="): if len(arg[len("--since="):]) > 1 { diff --git a/internal/run/run_test.go b/internal/run/run_test.go index 4a356d5c81020..5fc431c91df14 100644 --- a/internal/run/run_test.go +++ b/internal/run/run_test.go @@ -97,6 +97,40 @@ func TestParseConfig(t *testing.T) { cacheFolder: "node_modules/.cache/turbo", }, }, + { + "passThroughArgs", + []string{"foo", "--graph=g.png", "--", "--boop", "zoop"}, + &RunOptions{ + deps: true, + stream: true, + bail: true, + dotGraph: "g.png", + concurrency: 10, + ancestors: false, + cache: true, + forceExecution: false, + profile: "", + cacheFolder: "node_modules/.cache/turbo", + passThroughArgs: []string{"--boop", "zoop"}, + }, + }, + { + "Empty passThroughArgs", + []string{"foo", "--graph=g.png", "--"}, + &RunOptions{ + deps: true, + stream: true, + bail: true, + dotGraph: "g.png", + concurrency: 10, + ancestors: false, + cache: true, + forceExecution: false, + profile: "", + cacheFolder: "node_modules/.cache/turbo", + passThroughArgs: []string{}, + }, + }, } for i, tc := range cases {