Skip to content

fix(@angular/cli): throw error when specified project does not exist #17922

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

Conversation

kgajera
Copy link
Contributor

@kgajera kgajera commented Jun 12, 2020

Adds a check to see if the specified project exists, otherwise throws an error. This prevents it from falling through to the "build target not supported" error which is misleading.

Closes #17682

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Hi @kgajera,

Thanks for this, however I think a better approach would to throw an exception when a project doesn't exist in the first place which would also make the error message clearer.

You can add the below check right above the for..of.

let projectName = options.project;
if (projectName && !this._workspace.projects.has(projectName)) {
    throw new Error(`Project '${projectName}' does not exist.`);
}

@alan-agius4 alan-agius4 added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jun 15, 2020
@kgajera kgajera force-pushed the improve-project-target-not-found-error branch from 11b33cf to c9d52ee Compare June 15, 2020 19:34
Currently this falls through to a misleading error for an unsupported build target.

Closes angular#17682
@kgajera kgajera force-pushed the improve-project-target-not-found-error branch from c9d52ee to a097fe0 Compare June 15, 2020 21:01
@kgajera
Copy link
Contributor Author

kgajera commented Jun 15, 2020

@alan-agius4 Thanks, made the change.

@kgajera kgajera changed the title fix(@angular/cli): change project target not found error wording fix(@angular/cli): throw error when specified project does not exist Jun 15, 2020
Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

Thanks LGTM

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jun 16, 2020
@alan-agius4 alan-agius4 merged commit ba0f7ac into angular:master Jun 16, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ng build and ng serve with --project should clearly indicate that a project is unrecognized
3 participants