Skip to content

Commit

Permalink
fix(@schematics/angular): Transfer baseHref when during update process
Browse files Browse the repository at this point in the history
fixes #10915
  • Loading branch information
Brocco authored and hansl committed Jun 6, 2018
1 parent f2d5bbf commit 9a1210c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/schematics/angular/migrations/update-6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ function extractProjectsConfig(
index: `${appRoot}/${app.index || defaults.index}`,
main: `${appRoot}/${app.main || defaults.main}`,
tsConfig: `${appRoot}/${app.tsconfig || defaults.tsConfig}`,
...(app.baseHref ? { baseHref: app.baseHref } : {}),
...buildDefaults,
};

Expand Down
16 changes: 16 additions & 0 deletions packages/schematics/angular/migrations/update-6/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,22 @@ describe('Migration to v6', () => {
});
});

it('should not set baseHref on build & serve targets if not defined', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const build = getConfig(tree).projects.foo.architect.build;
expect(build.options.baseHref).toBeUndefined();
});

it('should set baseHref on build & serve targets if defined', () => {
const config = {...baseConfig};
config.apps[0].baseHref = '/base/href/';
tree.create(oldConfigPath, JSON.stringify(config, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const build = getConfig(tree).projects.foo.architect.build;
expect(build.options.baseHref).toEqual('/base/href/');
});

it('should add serviceWorker to production configuration', () => {
baseConfig.apps[0].serviceWorker = true;
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
Expand Down

0 comments on commit 9a1210c

Please sign in to comment.