-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
88 lines (78 loc) · 2.23 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const gulp = require('gulp');
const merge = require('gulp-merge-json');
const json5 = require('gulp-json5-to-json');
const package = require('./package.json');
const homedir = require('os').homedir();
const edit = require('gulp-json-editor');
const prettier = require('gulp-prettier');
const prettierConfig = require('./.prettierrc.json');
const scopes = package.contributes.grammars.map(scope => scope.scopeName);
function watch() {
return gulp.watch('./src/grammar/**/*.json5', gulp.series(['compile:grammar']));
}
gulp.task('compile', done => {
scopes.forEach(scope => {
gulp
.src('./src/grammar/**/*.json5')
.pipe(
merge({
fileName: `${scope}.json`,
json5: true,
}),
)
.pipe(
json5({
beautify: true,
}),
)
.pipe(
edit({
scopeName: `${scope}`,
}),
)
.pipe(prettier({ ...prettierConfig, editorConfig: true }))
.pipe(gulp.dest('./syntaxes'));
});
done();
});
gulp.task('compile:color-customizations', done => {
gulp
.src('./src/color-customizations/*.json5')
.pipe(
merge({
concatArrays: true,
fileName: 'tokens.json',
json5: true,
mergeArrays: true,
}),
)
.pipe(
json5({
beautify: true,
}),
)
.pipe(prettier({ ...prettierConfig, editorConfig: true }))
.pipe(gulp.dest('./src/ts/resources'));
done();
});
gulp.task('copy', done => {
scopes.forEach(scope => {
gulp
.src(`./syntaxes/${scope}.json`)
.pipe(
gulp.dest(`${homedir}/.vscode/extensions/${package.publisher}.${package.name}-${package.version}/syntaxes`),
);
});
gulp
.src(['./out/**/*'])
.pipe(gulp.dest(`${homedir}/.vscode/extensions/${package.publisher}.${package.name}-${package.version}/out`));
gulp
.src(`./package.json`)
.pipe(gulp.dest(`${homedir}/.vscode/extensions/${package.publisher}.${package.name}-${package.version}`));
done();
});
gulp.task('copy', gulp.series(['copy']));
gulp.task('compile:grammar', gulp.series(['compile']));
gulp.task('compile:color-customizations', gulp.series(['compile:color-customizations']));
gulp.task('watch', () => watch());
gulp.task('default', () => watch());