Skip to content

Commit

Permalink
Merge pull request #180 from jannis-baum/issue/179-support-config-dir…
Browse files Browse the repository at this point in the history
…ectory
  • Loading branch information
jannis-baum authored Sep 5, 2024
2 parents 649cfe0 + bc70a8c commit b665180
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
];
Expand All @@ -63,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
Expand Down

0 comments on commit b665180

Please sign in to comment.