Skip to content

Commit 785b4b1

Browse files
filipesilvaalexeagle
authored andcommitted
fix(@schematics/angular): workaround bug in recorder/update
1 parent d88175d commit 785b4b1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/schematics/angular/migrations/update-8/differential-loading.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,21 @@ function updateBrowserlist(): Rule {
112112

113113
const browserslistPath = join(normalize(project.root), 'browserslist');
114114
if (typeof project.sourceRoot === 'string') {
115+
// Move the CLI 7 style browserlist to root if it's there.
115116
const srcBrowsersList = join(normalize(project.sourceRoot), 'browserslist');
116-
if (tree.exists(srcBrowsersList)) {
117-
tree.rename(srcBrowsersList, browserslistPath);
117+
if (tree.exists(srcBrowsersList) && !tree.exists(browserslistPath)) {
118+
// TODO: use rename instead.
119+
// This is a hacky workaround. We should be able to just rename it.
120+
// On unit tests the rename works fine but on real projects it fails with
121+
// ERROR! browserslist does not exist..
122+
// This seems to happen because we are both renaming and then commiting an update.
123+
// But it's fine if we read/create/delete. There's a bug somewhere.
124+
// tree.rename(srcBrowsersList, browserslistPath);
125+
const content = tree.read(srcBrowsersList);
126+
if (content) {
127+
tree.create(browserslistPath, content);
128+
tree.delete(srcBrowsersList);
129+
}
118130
}
119131
}
120132

0 commit comments

Comments
 (0)