Skip to content

Commit

Permalink
fix(@angular/cli): improve error message for project-specific ng comm…
Browse files Browse the repository at this point in the history
…ands when run outside of a project

With this change we improve the error message when a project for command cannot be determined

```
Error: Cannot determine project for command.
This is a multi-project workspace and more than one project supports this command. Run "ng build [project]" to execute the command for a specific project or change the current working directory to a project directory.

Available projects are:
- project-name-0
- project-name-1
- project-name-2
- project-name-3
- project-name-4
- project-name-5
- project-name-6
- project-name-7
- project-name-8
- project-name-9
```

Closes angular#23481
  • Loading branch information
alan-agius4 committed Jul 1, 2022
1 parent d6b9306 commit c14da57
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export abstract class ArchitectCommandModule
if (!getYargsCompletions && !help) {
// Only issue the below error when not in help / completion mode.
throw new CommandModuleError(
'Cannot determine project for command. ' +
'Pass the project name as a command line argument or change the current working directory to a project directory.',
'Cannot determine project for command.\n' +
'This is a multi-project workspace and more than one project supports this command. ' +
`Run "ng ${this.command}" to execute the command for a specific project or change the current ` +
'working directory to a project directory.\n\n' +
`Available projects are:\n${allProjectsForTargetName.map((p) => `- ${p}`).join('\n')}`,
);
}
}
Expand Down

0 comments on commit c14da57

Please sign in to comment.