From d1f8fe604cf01c934ead4b74c9dbc9d014b5341a Mon Sep 17 00:00:00 2001 From: Jannis Baum Date: Wed, 4 Sep 2024 19:54:59 -0500 Subject: [PATCH 1/3] feat(#179): support .config dir --- src/config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/config.ts b/src/config.ts index a250515c..2759a676 100644 --- a/src/config.ts +++ b/src/config.ts @@ -38,6 +38,8 @@ const envConfigs: [string, keyof Config][] = [ const configFileBlocked: (keyof Config)[] = ['port']; const configPaths = [ + path.join(homedir(), '.config', 'vivify', 'config.json'), + path.join(homedir(), '.config', 'vivify.json'), path.join(homedir(), '.vivify', 'config.json'), path.join(homedir(), '.vivify.json'), ]; From 209eaff9c1dc4b6eea176e2d1c4c2ee07e0d8d3a Mon Sep 17 00:00:00 2001 From: Jannis Baum Date: Wed, 4 Sep 2024 19:56:52 -0500 Subject: [PATCH 2/3] docs(#179): document .config directory --- docs/customization.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/customization.md b/docs/customization.md index ce152db7..c7e35f47 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -5,9 +5,15 @@ while being built for maximal customizability. ## Configuration file -Vivify will look for an optional config file at `~/.vivify/config.json` and -`~/.vivify.json`. This file should contain a JSON object that can have the -following optional keys: +Vivify will look for an optional config file at + +- `~/.config/vivify/config.json`, +- `~/.config/vivify.json`, +- `~/.vivify/config.json`, and +- `~/.vivify.json`. + +This file should contain a JSON object that can have the following optional +keys: - **`"styles"`**\ A path to a single custom style sheet, or an array of multiple style sheets From bc70a8cdc9ef3462410e4500cb7503fc06d7b80a Mon Sep 17 00:00:00 2001 From: Jannis Baum Date: Thu, 5 Sep 2024 09:00:34 -0500 Subject: [PATCH 3/3] change(#179): break config retrieval on invalid JSON --- src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 2759a676..7bebd8e9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -65,8 +65,8 @@ const config = ((): Config => { if (!fs.existsSync(cp)) continue; try { config = JSON.parse(fs.readFileSync(cp, 'utf8')); - break; } catch {} + break; } // revert to default config if no config found