Skip to content

fix(@schematics/angular): move and update existing src/browserslist #14241

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
merged 1 commit into from
Apr 23, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,18 @@ function updateBrowserlist(): Rule {
continue;
}

const browserslistPath = join(normalize(project.root), '/browserslist');
const browserslistPath = join(normalize(project.root), 'browserslist');
if (typeof project.sourceRoot === 'string') {
const srcBrowsersList = join(normalize(project.sourceRoot), 'browserslist');
if (tree.exists(srcBrowsersList)) {
tree.rename(srcBrowsersList, browserslistPath);
}
}

const source = tree.read(browserslistPath);
if (!source) {
tree.create(browserslistPath, browserslistContent);
} else {
} else if (!source.toString().toLowerCase().includes('chrome 41')) {
const recorder = tree.beginUpdate(browserslistPath);
recorder.insertRight(source.length, '\nChrome 41 # Googlebot');
tree.commitUpdate(recorder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,15 @@ describe('Migration to version 8', () => {
expect(tree2.readContent('/browserslist'))
.toContain('Googlebot support');
});

it('should move browserslist file if it exists in the sourceRoot', () => {
tree.create('/src/browserslist', 'last 2 Chrome versions');
tree.delete('/browserslist');
const tree2 = schematicRunner.runSchematic('migration-07', {}, tree.branch());
Copy link
Contributor

Choose a reason for hiding this comment

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

I am confused why these all say migration-07

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the migration name. For example for Angular CLI version 8, we have multiple migrations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

expect(tree2.exists('/browserslist')).toBe(true);
const content = tree2.readContent('/browserslist');
expect(content).toContain('Chrome 41');
expect(content).toContain('last 2 Chrome versions');
});
});
});