From e71b1cb5f9846cc6e4fa29ff79d178464589cfb6 Mon Sep 17 00:00:00 2001 From: danielwerg <35052399+danielwerg@users.noreply.github.com> Date: Tue, 21 Oct 2025 16:32:40 +0300 Subject: [PATCH] feat: expand home dir path --- src/themes.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/themes.ts b/src/themes.ts index ed8ff83..3ac47e9 100644 --- a/src/themes.ts +++ b/src/themes.ts @@ -1,6 +1,7 @@ import * as assert from 'assert'; import * as path from 'path'; import * as fs from 'fs'; +import * as os from 'os'; import * as shiki from 'shiki'; /** @@ -159,12 +160,19 @@ export function parseColorDefinition(definition: ColorDefinition): ThemeColor { }; } +function expandHomeDir(path: string) { + const homeDir = os.homedir() + return path.replace('~', homeDir).replace('$HOME', homeDir) +} + function loadThemeDefinition( themesDir: string, themeName: string ): ThemeDefinition { return JSON.parse( - fs.readFileSync(path.join(themesDir, `${themeName}.json`)).toString() + fs.readFileSync( + expandHomeDir(path.join(themesDir, `${themeName}.json`)) + ).toString() ) as ThemeDefinition; }