Skip to content
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

ng g @angular/fire:ng-add fails in a project where sourceRoot starts with the project's root #3052

Closed
AgentEnder opened this issue Nov 9, 2021 · 2 comments · Fixed by #3053

Comments

@AgentEnder
Copy link
Contributor

AgentEnder commented Nov 9, 2021

Version info

Angular: 12.2.0

Firebase: latest

AngularFire: latest

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

This can be easily reproduced in Nx by following these steps, but would occur in a regular Angular project if the angular.json file had a similar project configuration to below. Reproduction steps for Nx are found in the Issue mention, for angular just ng new and update the configuration.

Debug output

** Screenshots **
image

Expected behavior

ng add @angular/fire passes if sourceRoot and root are both relative to the workspace root

Actual behavior

ng add @angular/fire only passes if sourceRoot is relative to root


In a workspace with a project configured as below, ng add @angular/fire fails due to the sourceRoot path being appended to the root, rather than replacing it.

{
  "root": "apps/admin"
  "sourceRoot": "apps/admin/src"
}

const sourcePath = [project.root, project.sourceRoot].filter(it => !!it).join('/');

Maybe this portion of code could use something like

const sourcePath = project.sourceRoot?.startsWith(project.root) 
		? project.sourceRoot 
		: [project.root, project.sourceRoot].filter(it => !!it).join('/'); 

I'd be happy to put in a PR to make the change if its agreed upon.

@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@jamesdaniels
Copy link
Member

Oh whooops, good catch, feel free to send a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants