mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
docs(themes): handle non-json themes
This commit is contained in:
parent
5c3a7685c9
commit
895d1f3b52
|
@ -18,6 +18,10 @@ function newThemeConfig(rpromptOffset = 40, cursorPadding = 30, author = "", bgC
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidTheme(theme) {
|
||||||
|
return theme.endsWith('.omp.json') || theme.endsWith('.omp.toml') || theme.endsWith('.omp.yaml')
|
||||||
|
}
|
||||||
|
|
||||||
let themeConfigOverrrides = new Map();
|
let themeConfigOverrrides = new Map();
|
||||||
themeConfigOverrrides.set('agnoster.omp.json', newThemeConfig(40, 40));
|
themeConfigOverrrides.set('agnoster.omp.json', newThemeConfig(40, 40));
|
||||||
themeConfigOverrrides.set('agnosterplus.omp.json', newThemeConfig(80));
|
themeConfigOverrrides.set('agnosterplus.omp.json', newThemeConfig(80));
|
||||||
|
@ -62,7 +66,7 @@ themeConfigOverrrides.set('zash.omp.json', newThemeConfig(40, 40));
|
||||||
let links = new Array();
|
let links = new Array();
|
||||||
|
|
||||||
for (const theme of themes) {
|
for (const theme of themes) {
|
||||||
if (!theme.endsWith('.omp.json')) {
|
if (!isValidTheme(theme)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const configPath = path.join(themesConfigDir, theme);
|
const configPath = path.join(themesConfigDir, theme);
|
||||||
|
@ -87,13 +91,12 @@ themeConfigOverrrides.set('zash.omp.json', newThemeConfig(40, 40));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const image = theme.replace('.omp.json', '.png');
|
const themeName = theme.slice(0, -9);
|
||||||
|
const image = themeName + '.png';
|
||||||
const toPath = path.join(themesStaticDir, image);
|
const toPath = path.join(themesStaticDir, image);
|
||||||
|
|
||||||
await fs.promises.rename(image, toPath);
|
await fs.promises.rename(image, toPath);
|
||||||
|
|
||||||
const themeName = theme.replace('.omp.json', '');
|
|
||||||
|
|
||||||
const themeData = `
|
const themeData = `
|
||||||
### [${themeName}]
|
### [${themeName}]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue