File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ const THREE_REGEX = /three@[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)/gm;
3
3
let NEW_THREE_VERSION ;
4
4
const THREE_PACKAGE_REGEX = / " t h r e e " : " .* " / g;
5
5
fs . 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 ( '"' , '' ) } `;
7
8
console . log ( NEW_THREE_VERSION ) ;
8
9
} ) ;
9
10
@@ -14,9 +15,15 @@ function updateThreeVersion(filePath) {
14
15
return ;
15
16
}
16
17
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
+ }
17
23
data = data . replaceAll ( OLD_THREE_VERSION , NEW_THREE_VERSION ) ;
18
24
fs . writeFile ( filePath , data , { encoding : 'utf8' } , ( err ) => {
19
- if ( err ) console . log ( err ) ;
25
+ if ( err )
26
+ console . log ( err ) ;
20
27
} ) ;
21
28
} ) ;
22
29
}
You can’t perform that action at this time.
0 commit comments