Skip to content

Commit

Permalink
improve error handling for commands in singlePackage projects (#3243)
Browse files Browse the repository at this point in the history
Currently in 'single package mode' the error message for missing turbo
commands is a little misleading:

```bash
turbo-single-test on  main [?] is 📦 v1.0.0 via  v19.4.0 
❯ ../turbo/target/debug/turbo ls
 ERROR  run failed: task `ls` not found in turbo `pipeline` in "turbo.json". Are you sure you added it?
Turbo error: task `ls` not found in turbo `pipeline` in "turbo
```

This PR makes a small change to the validation to respect the
`singlePackage` option.

```bash
turbo-single-test on  main [?] is 📦 v1.0.0 via  v19.4.0 
❯ ../turbo/target/debug/turbo ls
 ERROR  run failed: task `ls` not found in `scripts` in "package.json"
Turbo error: task `ls` not found in `scripts` in "package.json"
```

Co-authored-by: Thomas Knickman <tom.knickman@vercel.com>
  • Loading branch information
arlyon and tknickman committed Jan 10, 2023
1 parent 40d6d18 commit 91dda20
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ func (r *run) run(ctx gocontext.Context, targets []string) error {

pipeline := turboJSON.Pipeline
if err := validateTasks(pipeline, targets); err != nil {
return err
location := ""
if r.opts.runOpts.singlePackage {
location = "in `scripts` in \"package.json\""
} else {
location = "in `pipeline` in \"turbo.json\""
}
return fmt.Errorf("%s %s. Are you sure you added it?", err, location)
}

scmInstance, err := scm.FromInRepo(r.base.RepoRoot)
Expand Down Expand Up @@ -436,7 +442,7 @@ const (
func validateTasks(pipeline fs.Pipeline, tasks []string) error {
for _, task := range tasks {
if !pipeline.HasTask(task) {
return fmt.Errorf("task `%v` not found in turbo `pipeline` in \"turbo.json\". Are you sure you added it?", task)
return fmt.Errorf("task `%v` not found", task)
}
}
return nil
Expand Down

1 comment on commit 91dda20

@vercel
Copy link

@vercel vercel bot commented on 91dda20 Jan 10, 2023

Choose a reason for hiding this comment

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

You must have Developer access to commit code to Vercel on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/concepts/teams/roles-and-permissions#enterprise-team-account-roles

Please sign in to comment.