@@ -12,8 +12,9 @@ const hook: Hook<'init'> = async function (opts) {
1212 const curDateTime = new Date ( )
1313 const configFileExists = fs . existsSync ( path . join ( this . config . configDir , 'config.json' ) )
1414
15- const createConfigDir = async ( path : string ) => {
15+ const writeUserConfig = async ( userconfig : any ) => {
1616 await fs . mkdirp ( this . config . configDir )
17+ await fs . writeFile ( path . join ( this . config . configDir , 'config.json' ) , JSON . stringify ( userconfig , null , 2 ) )
1718 }
1819
1920 try {
@@ -37,10 +38,9 @@ const hook: Hook<'init'> = async function (opts) {
3738 }
3839 }
3940
40- const updateUserConfig = ( curVersionCheck : Date ) => {
41+ const updateUserConfig = async ( curVersionCheck : Date ) => {
4142 userConfig . lastVersionCheck = curVersionCheck
42- createConfigDir ( this . config . configDir )
43- fs . writeFileSync ( path . join ( this . config . configDir , 'config.json' ) , JSON . stringify ( userConfig , null , 2 ) )
43+ await writeUserConfig ( userConfig )
4444 }
4545
4646 const isToday = ( dateObj : Date | null , today : Date ) => {
@@ -81,9 +81,7 @@ const hook: Hook<'init'> = async function (opts) {
8181 this . log ( chalk . blue ( 'bf config:telemetry:enable' ) )
8282 }
8383
84- createConfigDir ( this . config . configDir )
85-
86- await fs . writeFile ( path . join ( this . config . configDir , 'config.json' ) , JSON . stringify ( userConfig , null , 2 ) )
84+ await writeUserConfig ( userConfig )
8785 }
8886
8987 this . config . pjson . telemetry = userConfig . telemetry
0 commit comments