-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgulpfile.js
More file actions
79 lines (64 loc) · 2.32 KB
/
gulpfile.js
File metadata and controls
79 lines (64 loc) · 2.32 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// TODO: Deprecate usage of gulpjs altogether.
import { join } from 'node:path';
import { exec } from 'node:child_process';
import { series, src, dest, task } from 'gulp';
const SYNTAX_TASK = (() => {
const TASK_NAME = 'compileSyntax';
const dir = 'syntaxes/';
const languagePath = join(dir, 'UnrealScript.YAML-tmLanguage');
const ppLanguagePath = join(dir, 'unrealscript.preprocessor.YAML-tmLanguage');
task(TASK_NAME, (done) => {
// We could use js-yaml directly, but I would prefer to deprecate gulpjs altogether instead.
exec('npm run compile:syntax', (err, stdout, stderr) => {
console.log(stdout);
console.error(stderr);
done();
});
});
if (process.env.NODE_ENV === 'development') {
const FILES_TO_WATCH = [ppLanguagePath, languagePath];
watch(FILES_TO_WATCH, (cb) => {
return task(TASK_NAME)(cb);
});
}
return TASK_NAME;
})();
const GRAMMAR_TASK = (() => {
const TASK_NAME = 'buildGrammar';
const dir = 'grammars/';
const lexerPath = join(dir, 'UCLexer.g4');
const parserPath = join(dir, 'UCParser.g4');
const ppParserPath = join(dir, 'UCPreprocessorParser.g4');
task(TASK_NAME, (done) => {
/* `cd node_modules/antlr4ts-cli && antlr4ts -visitor ${GRAMMAR_PATH} -o server/src/antlr` */
exec('npm run compile:grammar', (err, stdout, stderr) => {
console.log(stdout);
console.error(stderr);
done();
});
});
if (process.env.NODE_ENV === 'development') {
const FILES_TO_WATCH = [lexerPath, parserPath, ppParserPath];
watch(FILES_TO_WATCH, (cb) => {
return task(TASK_NAME)(cb);
});
}
return TASK_NAME;
})();
// Copy all the UnrealScript presets to the 'out' directory
const PRESETS_TASK = (() => {
const TASK_NAME = 'copy presets';
const filesGlob = 'server/src/presets/**/*.uc';
task(TASK_NAME, (done) => {
return src(filesGlob)
.pipe(dest(join('out', 'presets/')));
});
if (process.env.NODE_ENV === 'development') {
const FILES_TO_WATCH = [filesGlob];
watch(FILES_TO_WATCH, (cb) => {
return task(TASK_NAME)(cb);
});
}
return TASK_NAME;
})();
task('default', series([GRAMMAR_TASK, SYNTAX_TASK, PRESETS_TASK]));