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

fix(schematics): ng-add should pass if sourceRoot is relative to workspace root #3053

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/schematics/ng-add.jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,20 @@ describe('ng-add', () => {
expect(result.read('.firebaserc').toString()).toEqual(overwriteFirebaserc);
expect(result.read('angular.json').toString()).toEqual(overwriteAngularJson);
});

it('runs if source root is relative to workspace root', async () => {
const angularJson = generateAngularJson();
const project: {root: string, sourceRoot?: string} = angularJson.projects[PROJECT_NAME];
project.sourceRoot = `${project.root}/src`;
tree.overwrite('angular.json', JSON.stringify(angularJson));
const promise = setupProject(tree, {} as any, [FEATURES.Hosting], {
firebaseProject: { projectId: FIREBASE_PROJECT } as any,
projectType: PROJECT_TYPE.Static,
project: undefined,
prerender: false,
});
await expectAsync(promise).toBeResolved();
});

it('overrides existing files', async () => {
const tempTree = await setupProject(tree, {} as any, [FEATURES.Hosting], {
Expand Down
2 changes: 1 addition & 1 deletion src/schematics/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const setupProject =

const { project, projectName } = getProject(config, tree);

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

addIgnoreFiles(tree);

Expand Down