-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (54 loc) · 1.99 KB
/
gulpfile.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { series } = require('gulp');
var shell = require('shelljs');
function compile(cb) {
if (shell.exec('nearleyc .\\grammar\\psych_script.ne -o .\\psych_script_compiled.js').code !== 0) {
shell.echo('Error: Browserify Command failed');
shell.exit(1);
}
cb();
}
function browserify_generate_js(cb) {
if (shell.exec('browserify .\\psych_generate.js -o .\\psych_generate_browser.js').code !== 0) {
shell.echo('Error: Browserify Command failed');
shell.exit(1);
}
cb();
}
function generate_railroad_diagrams(cb) {
if (shell.exec('nearley-railroad .\\grammar\\psych_script.ne -o .\\docs\\psych_railroad.html').code !== 0) {
shell.echo('Error: railroad psych_script Command failed');
shell.exit(1);
}
if (shell.exec('nearley-railroad .\\grammar\\psych_case_discovery.ne -o .\\docs\\psych_case_discovery_railroad.html').code !== 0) {
shell.echo('Error: railroad psych_script Command failed');
shell.exit(1);
}
if (shell.exec('nearley-railroad .\\grammar\\psych_speech.ne -o .\\docs\\psych_speech_railroad.html').code !== 0) {
shell.echo('Error: railroad psych_speech Command failed');
shell.exit(1);
}
if (shell.exec('nearley-railroad .\\grammar\\psych_settings.ne -o .\\docs\\psych_settings_railroad.html').code !== 0) {
shell.echo('Error: railroad psych_settings Command failed');
shell.exit(1);
}
if (shell.exec('nearley-railroad .\\grammar\\psych_characters.ne -o .\\docs\\psych_characters_railroad.html').code !== 0) {
shell.echo('Error: railroad psych_characters Command failed');
shell.exit(1);
}
cb();
}
function run(cb) {
shell.exec('node ./psych_generate.js', function(code, stdout, stderr) {
if(code !== 0){
console.log('Program stderr:', stderr);
shell.exit(1);
}
});
cb();
}
exports.default = series(compile, browserify_generate_js);
exports.build = series(compile, browserify_generate_js, generate_railroad_diagrams);
exports.compile = compile;
exports.run = run;
exports.browserify = browserify_generate_js;
exports.railroad = generate_railroad_diagrams;