Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/themes.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -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;
}

Expand Down