Skip to content

Commit

Permalink
fix(schematics): ng-add should pass if sourceRoot is relative to work…
Browse files Browse the repository at this point in the history
…space root (#3053)
  • Loading branch information
AgentEnder authored Nov 11, 2021
1 parent 5ecf875 commit 7e931cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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

0 comments on commit 7e931cb

Please sign in to comment.