-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
28 lines (22 loc) · 948 Bytes
/
build.js
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
const fs = require('fs');
const YAML = require('yaml');
const KaitaiStructCompiler = require('kaitai-struct-compiler');
const compiler = new KaitaiStructCompiler();
console.log('Kaitai Struct Compiler Version:', compiler.version);
console.log('Kaitai Struct Compiler Build date:', compiler.buildDate);
console.log('Kaitai Struct Compiler Supported languages:', compiler.languages.join(', '));
const ksyYaml = fs.readFileSync('aseprite.ksy', 'utf-8');
const ksy = YAML.parse(ksyYaml);
compiler.compile('javascript', ksy, null, false).then(files => {
console.log('Generated:', ...Object.keys(files));
if (!files['Aseprite.js']) {
throw new Error('Did not generated expected file: Aseprite.js');
}
console.log('Writing aseprite.js...');
fs.writeFileSync('aseprite.js', files['Aseprite.js']);
console.log('DONE');
}).catch(error => {
console.error(error.stack);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
});