@@ -88,26 +88,16 @@ export function updateES5Projects(): Rule {
8888 }
8989
9090 const browserslistPath = join ( normalize ( project . root ) , 'browserslist' ) ;
91- if ( typeof project . sourceRoot === 'string' ) {
92- // Move the CLI 7 style browserlist to root if it's there.
93- const srcBrowsersList = join ( normalize ( project . sourceRoot ) , 'browserslist' ) ;
94- if ( tree . exists ( srcBrowsersList ) && ! tree . exists ( browserslistPath ) ) {
95- // TODO: use rename instead.
96- // This is a hacky workaround. We should be able to just rename it.
97- // On unit tests the rename works fine but on real projects it fails with
98- // ERROR! browserslist does not exist..
99- // This seems to happen because we are both renaming and then commiting an update.
100- // But it's fine if we read/create/delete. There's a bug somewhere.
101- // tree.rename(srcBrowsersList, browserslistPath);
102- const content = tree . read ( srcBrowsersList ) ;
103- if ( content ) {
104- tree . create ( browserslistPath , content ) ;
105- tree . delete ( srcBrowsersList ) ;
106- }
107- }
108- }
10991
110- if ( ! tree . exists ( browserslistPath ) ) {
92+ // Move the CLI 7 style browserlist to root if it's there.
93+ const sourceRoot = project . sourceRoot === 'string'
94+ ? project . sourceRoot
95+ : join ( normalize ( project . root ) , 'src' ) ;
96+ const srcBrowsersList = join ( normalize ( sourceRoot ) , 'browserslist' ) ;
97+
98+ if ( tree . exists ( srcBrowsersList ) ) {
99+ tree . rename ( srcBrowsersList , browserslistPath ) ;
100+ } else if ( ! tree . exists ( browserslistPath ) ) {
111101 tree . create ( browserslistPath , browserslistContent ) ;
112102 }
113103 }
0 commit comments