File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,16 @@ export class ReactTemplate implements Template {
123123 igniteuiResFile = igniteuiResFile . replace ( freeVersionPath , fullVersionPath ) ;
124124 igniteuiResFile = igniteuiResFile . replace ( "-lite" , "" ) ;
125125 }
126- fs . writeFileSync ( igResPath , igniteuiResFile ) ;
126+
127+ const fd = fs . openSync ( igResPath , fs . constants . O_WRONLY | fs . constants . O_TRUNC ) ;
128+ fs . writeSync ( fd , igniteuiResFile ) ;
129+ fs . closeSync ( fd ) ;
127130 }
128131
129132 if ( dvDep && ! igniteuiResFile . includes ( dvPath ) ) {
130- fs . appendFileSync ( igResPath , `${ '\r\n// Ignite UI Charts Required JavaScript File\r\nimport "'
131- + dvPath + '";\r\n' } `) ;
133+ const fd = fs . openSync ( igResPath , fs . constants . O_WRONLY | fs . constants . O_APPEND ) ;
134+ fs . writeSync ( fd , `\r\n// Ignite UI Charts Required JavaScript File\r\nimport "${ dvPath } ";\r\n` ) ;
135+ fs . closeSync ( fd ) ;
132136 }
133137
134138 } else {
Original file line number Diff line number Diff line change @@ -69,16 +69,16 @@ class GoogleAnalytics {
6969 protected static getUUID ( ) : string {
7070 const absolutePath = path . join ( this . userDataFolder , this . appFolder , this . userSettings ) ;
7171 let UUID = "" ;
72- if ( fs . existsSync ( absolutePath ) ) {
73- UUID = require ( absolutePath ) . UUID ;
74- } else {
75- const dirName = path . dirname ( absolutePath ) ;
76- if ( ! fs . existsSync ( dirName ) ) {
77- fs . mkdirSync ( dirName ) ;
78- }
72+ const dirName = path . dirname ( absolutePath ) ;
73+ fs . mkdirSync ( dirName , { recursive : true } ) ;
7974
75+ try {
76+ const fd = fs . openSync ( absolutePath , fs . constants . O_CREAT | fs . constants . O_EXCL | fs . constants . O_RDWR , 0o600 ) ;
8077 UUID = this . getUserID ( ) ;
81- fs . writeFileSync ( absolutePath , JSON . stringify ( { UUID } ) ) ;
78+ fs . writeFileSync ( fd , JSON . stringify ( { UUID } ) ) ;
79+ fs . closeSync ( fd ) ;
80+ } catch {
81+ UUID = JSON . parse ( fs . readFileSync ( absolutePath , "utf8" ) ) . UUID ;
8282 }
8383
8484 return UUID ;
You can’t perform that action at this time.
0 commit comments