Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit 5b09aa2

Browse files
author
Jonathan Spruance (Insight Global)
committed
Write config folder in it doesn't exist, extract into common function
1 parent 777067b commit 5b09aa2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/cli/src/hooks/init/inithook.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ 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) => {
16+
await fs.mkdirp(this.config.configDir)
17+
}
18+
1519
try {
1620
// if config file exists, load settings
1721
if (configFileExists) {
@@ -35,6 +39,7 @@ const hook: Hook<'init'> = async function (opts) {
3539

3640
const updateUserConfig = (curVersionCheck: Date) => {
3741
userConfig.lastVersionCheck = curVersionCheck
42+
createConfigDir(this.config.configDir)
3843
fs.writeFileSync(path.join(this.config.configDir, 'config.json'), JSON.stringify(userConfig, null, 2))
3944
}
4045

@@ -76,7 +81,7 @@ const hook: Hook<'init'> = async function (opts) {
7681
this.log(chalk.blue('bf config:telemetry:enable'))
7782
}
7883

79-
await fs.mkdirp(this.config.configDir)
84+
createConfigDir(this.config.configDir)
8085

8186
await fs.writeFile(path.join(this.config.configDir, 'config.json'), JSON.stringify(userConfig, null, 2))
8287
}

0 commit comments

Comments
 (0)