mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 23:15:56 +08:00
fix(@schematics/angular): workaround bug in recorder/update
This commit is contained in:
parent
d88175ddf1
commit
785b4b1049
@ -112,9 +112,21 @@ function updateBrowserlist(): Rule {
|
|||||||
|
|
||||||
const browserslistPath = join(normalize(project.root), 'browserslist');
|
const browserslistPath = join(normalize(project.root), 'browserslist');
|
||||||
if (typeof project.sourceRoot === 'string') {
|
if (typeof project.sourceRoot === 'string') {
|
||||||
|
// Move the CLI 7 style browserlist to root if it's there.
|
||||||
const srcBrowsersList = join(normalize(project.sourceRoot), 'browserslist');
|
const srcBrowsersList = join(normalize(project.sourceRoot), 'browserslist');
|
||||||
if (tree.exists(srcBrowsersList)) {
|
if (tree.exists(srcBrowsersList) && !tree.exists(browserslistPath)) {
|
||||||
tree.rename(srcBrowsersList, browserslistPath);
|
// TODO: use rename instead.
|
||||||
|
// This is a hacky workaround. We should be able to just rename it.
|
||||||
|
// On unit tests the rename works fine but on real projects it fails with
|
||||||
|
// ERROR! browserslist does not exist..
|
||||||
|
// This seems to happen because we are both renaming and then commiting an update.
|
||||||
|
// But it's fine if we read/create/delete. There's a bug somewhere.
|
||||||
|
// tree.rename(srcBrowsersList, browserslistPath);
|
||||||
|
const content = tree.read(srcBrowsersList);
|
||||||
|
if (content) {
|
||||||
|
tree.create(browserslistPath, content);
|
||||||
|
tree.delete(srcBrowsersList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user