Skip to content
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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');
});
});
});