Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"label": "Omni",
"uiTheme": "vs-dark",
"path": "./theme/omni.json"
},
{
"label": "Omni (No italic)",
"uiTheme": "vs-dark",
"path": "./theme/omni-no-italic.json"
}
]
},
Expand Down
49 changes: 48 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,66 @@ const path = require('path');
const generate = require('./generate');

const THEME_DIR = path.join(__dirname, '..', 'theme');
const BASE_THEME_FILENAME = 'omni.json';
const NO_ITALIC_THEME_FILENAME = 'omni-no-italic.json';

if (!fs.existsSync(THEME_DIR)) {
fs.mkdirSync(THEME_DIR);
}

const removeItalics = (theme) => {
const clone = JSON.parse(JSON.stringify(theme));

clone.name = 'Omni (No italic)';

const stripFontStyle = (settings) => {
if (!settings || typeof settings.fontStyle !== 'string') {
return;
}

const styles = settings.fontStyle
.split(/\s+/)
.map((style) => style.trim())
.filter((style) => style && style.toLowerCase() !== 'italic');

if (styles.length === 0) {
delete settings.fontStyle;
} else {
settings.fontStyle = styles.join(' ');
}
};

if (Array.isArray(clone.tokenColors)) {
clone.tokenColors.forEach((token) => stripFontStyle(token.settings));
}

if (
clone.semanticTokenColors &&
typeof clone.semanticTokenColors === 'object'
) {
Object.values(clone.semanticTokenColors).forEach((tokenSetting) => {
if (tokenSetting && typeof tokenSetting === 'object') {
stripFontStyle(tokenSetting);
}
});
}

return clone;
};

module.exports = async () => {
const { base } = await generate();
const noItalic = removeItalics(base);

return Promise.all([
fs.promises.writeFile(
path.join(THEME_DIR, 'omni.json'),
path.join(THEME_DIR, BASE_THEME_FILENAME),
JSON.stringify(base, null, 4)
),
fs.promises.writeFile(
path.join(THEME_DIR, NO_ITALIC_THEME_FILENAME),
JSON.stringify(noItalic, null, 4)
),
]);
};

Expand Down