File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const THREE_REGEX = /three@[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)/gm;
33let NEW_THREE_VERSION ;
44const THREE_PACKAGE_REGEX = / " t h r e e " : " .* " / g;
55fs . readFile ( 'package.json' , { encoding : 'utf8' } , ( err , data ) => {
6- NEW_THREE_VERSION = `three@${ THREE_PACKAGE_REGEX . exec ( data ) [ 0 ] . split ( ' ' ) [ 1 ] . replaceAll ( '"' , '' ) } ` ;
6+ NEW_THREE_VERSION = `three@${
7+ THREE_PACKAGE_REGEX . exec ( data ) [ 0 ] . split ( ' ' ) [ 1 ] . replaceAll ( '"' , '' ) } `;
78 console . log ( NEW_THREE_VERSION ) ;
89} ) ;
910
@@ -14,9 +15,15 @@ function updateThreeVersion(filePath) {
1415 return ;
1516 }
1617 const OLD_THREE_VERSION = THREE_REGEX . exec ( data ) [ 0 ] ;
18+ if ( ! OLD_THREE_VERSION || ! NEW_THREE_VERSION ) {
19+ console . error (
20+ 'Tried to replace ' , OLD_THREE_VERSION , ' with ' , NEW_THREE_VERSION ) ;
21+ return ;
22+ }
1723 data = data . replaceAll ( OLD_THREE_VERSION , NEW_THREE_VERSION ) ;
1824 fs . writeFile ( filePath , data , { encoding : 'utf8' } , ( err ) => {
19- if ( err ) console . log ( err ) ;
25+ if ( err )
26+ console . log ( err ) ;
2027 } ) ;
2128 } ) ;
2229}
You can’t perform that action at this time.
0 commit comments