diff options
| author | Leo Goetz <dev@leogtz.de> | 2026-05-24 13:37:55 +0200 |
|---|---|---|
| committer | Leo Goetz <dev@leogtz.de> | 2026-05-24 13:37:55 +0200 |
| commit | e765e1acdfe8e25c41b267eedd878c739d3e5261 (patch) | |
| tree | 9a6bd76623f42b0bb800e42394736480a630ce79 /src/utils/config.ts | |
| parent | ca8537af0ab596fddd8d72e6630f278326ef5360 (diff) | |
Diffstat (limited to 'src/utils/config.ts')
| -rw-r--r-- | src/utils/config.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/utils/config.ts b/src/utils/config.ts index 62080f7..0706312 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -3,7 +3,7 @@ import fs from "fs/promises"; import type { Config } from "../types.js"; const configPath: string = new URL( - `${os.homedir()}/.config/dephelp/`, + `${os.homedir()}/.config/dephelp`, import.meta.url, ).pathname; @@ -34,15 +34,11 @@ export const getConfig = async (): Promise<Config> => { export const initConfig = async () => { try { - await fs.access(configPath); + await fs.access(configFile); + console.log(`You already have a config at: ${configFile}`); } catch { - await fs.mkdir(configPath); - } - - try { + await fs.mkdir(configPath, { recursive: true }); await fs.writeFile(`${configFile}`, JSON.stringify(sampleConfig, null, 2)); - console.log(`Config got generated in /.config/dephelp/config.json`); - } catch (error) { - console.error(error); + console.log(`Config got generated: ${configFile}`); } }; |
