forked from DHedgecock/radical-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
51 lines (42 loc) · 1.74 KB
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { promises as fs } from 'fs'
// Load theme color variables
import colors from './theme/colors-workbench.mjs'
// Load terminal variables
import { terminal } from './theme/colors-tokens.mjs'
// Load syntax tokens
import tokens from './theme/syntax-tokens.mjs'
import { comment } from './theme/languages/comment.mjs'
import { markdown } from './theme/languages/markdown.mjs'
import { json } from './theme/languages/json.mjs'
import { yaml } from './theme/languages/yaml.mjs'
// Create the base theme definition
// ---------------------------------------------------------------------------
let theme = {
$schema: 'vscode://schemas/color-theme',
author: 'Dan Hedgecock',
name: 'Radical',
colorSpaceName: 'sRGB',
semanticClass: 'theme.dark.radical',
// Editor theme styles
colors: {
...colors,
...terminal,
},
tokenColors: [...tokens, ...comment, ...markdown, ...json, ...yaml],
}
// Convert color variables to string vlaues
// ---------------------------------------------------------------------------
// Delete any value that is null (as a convention this lets us track that all
// theme variables are being set by assigning values to all of them)
Object.keys(theme.colors).forEach((color) => {
if (theme.colors[color] === null) delete theme.colors[color]
})
// Stringify all of the combined theme styles so we can run string regexes on it to
// replace color variables with color values
theme = JSON.stringify(theme, null, 2)
// Base file has been extended with additional theme styles and color variables have
// been replaced with Panda theme values. Write to /dist for consumption.
fs.writeFile('dist/Radical.json', theme)
/* eslint-disable no-console */
.then(() => console.log('Build finished'))
.catch((err) => console.warn(err))