forked from wfpaisa/plane-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
39 lines (34 loc) · 1.11 KB
/
build.js
File metadata and controls
39 lines (34 loc) · 1.11 KB
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
const fs = require('fs');
const path = require('path');
const tinycolor = require('tinycolor2');
const yaml = require('js-yaml');
const THEME_DIR = path.join(__dirname, 'theme');
const THEME_YAML_FILE = path.join(__dirname, 'src', 'plane.yml');
const THEME_YAML_FILE_LIGHT = path.join(__dirname, 'src', 'plane-light.yml');
if (!fs.existsSync(THEME_DIR)) {
fs.mkdirSync(THEME_DIR);
}
const withAlphaType = new yaml.Type('!alpha', {
kind: 'sequence',
construct: data => {
if(data[1]<10){
return `${data[0]}0${data[1]}`;
}else{
return `${data[0]}${data[1]}`;
}
},
represent: data => {
return [data[0], data[1]];
},
});
const schema = yaml.Schema.create([withAlphaType]);
const standard = fs.readFileSync(THEME_YAML_FILE, 'utf8');
const standard_light = fs.readFileSync(THEME_YAML_FILE_LIGHT, 'utf8');
fs.writeFileSync(
path.join(THEME_DIR, 'plane.json'),
JSON.stringify(yaml.load(standard, { schema }), null, 4)
);
fs.writeFileSync(
path.join(THEME_DIR, 'plane-light.json'),
JSON.stringify(yaml.load(standard_light, { schema }), null, 4)
);