forked from dotnet/csharp-tmLanguage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
63 lines (50 loc) · 1.6 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
const gulp = require("gulp");
const mocha = require("gulp-mocha");
const json2cson = require("gulp-json2cson");
const yaml = require("gulp-yaml");
const ts = require("gulp-typescript");
const js_yaml = require("js-yaml");
const plist = require("plist");
const fs = require("fs");
const path = require("path");
const inputGrammar = "src/csharp.tmLanguage.yml";
const grammarsDirectory = "grammars/";
const jsOut = "out/";
function handleError(err) {
console.log(err.toString());
process.exit(-1);
}
gulp.task('buildTmLanguage', done => {
const text = fs.readFileSync(inputGrammar);
const jsonData = js_yaml.safeLoad(text);
const plistData = plist.build(jsonData);
if (!fs.existsSync(grammarsDirectory)) {
fs.mkdirSync(grammarsDirectory);
}
fs.writeFileSync(path.join(grammarsDirectory, 'csharp.tmLanguage'), plistData);
done();
});
gulp.task('buildAtom', () => {
return gulp.src(inputGrammar)
.pipe(yaml())
.pipe(json2cson())
.pipe(gulp.dest(grammarsDirectory))
.on("error", handleError);
});
gulp.task('compile', () => {
const tsProject = ts.createProject("./tsconfig.json");
return tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest(jsOut));
});
gulp.task('test', gulp.series('compile', done => {
const result = gulp.src(jsOut + "test/**/*.tests.js")
.pipe(mocha())
.on("error", handleError);
done();
return result;
}));
gulp.task('default',
gulp.series(
gulp.parallel('buildAtom', 'buildTmLanguage'),
'test'));