-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (46 loc) · 1.16 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
var gulp = require('gulp');
var runSequence = require('run-sequence');
var merge = require('merge2');
var del = require('del');
var fs = require('fs');
var ts = require('gulp-typescript');
var tsProject = ts.createProject('tsconfig.json', {
declaration: true
});
gulp.task('default', function () {
runSequence(
'clean',
'typescript',//-parser',
'build-parser'
//'typescript'
);
});
gulp.task('clean', function () {
return del([
'lib/**/*'
]);
});
gulp.task('typescript-parser', function () {
return gulp.src(['src/grammar.ts'])
.pipe(ts())
.pipe(gulp.dest('lib'));
});
gulp.task('build-parser', function () {
var extend = function(child, parent) {
for (var key in parent) {
if ({}.hasOwnProperty.call(parent, key)) child[key] = parent[key];
}
}
extend(global, require('util'));
require('jison');
var parser = require('./lib/grammar.js').parser.generate();
fs.writeFileSync('lib/parser.js', parser);
});
gulp.task('typescript', function () {
const tsResult = tsProject.src()
.pipe(tsProject());
return merge([
tsResult.dts.pipe(gulp.dest('src/typings')),
tsResult.js.pipe(gulp.dest('lib'))
]);
});