-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gulpfile.js
69 lines (59 loc) · 1.32 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
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
stream = require('event-stream'),
ts = require('gulp-typescript'),
jasmine = require('gulp-jasmine'),
concat = require('gulp-concat'),
cover = require('gulp-coverage');
var paths = {
src: 'src',
spec: 'spec',
dist: 'dist'
};
var files = {
src: paths.src + '/petri.ts',
spec: paths.spec + '/**/*.ts',
dist: paths.dist + '/petri.js',
min: paths.dist + '/petri.min.js',
def: paths.dist + '/petri.d.ts'
};
var tsProject = ts.createProject({
target: 'es5',
module: 'commonjs',
declarationFiles: true,
sortOutput: true
});
gulp.task('compile', function() {
var result = gulp.src(files.src)
.pipe(ts(tsProject));
return stream.merge(
result.js
.pipe(concat(files.dist))
.pipe(gulp.dest('.')),
result.dts
.pipe(gulp.dest(paths.dist))
);
});
gulp.task('test', function() {
return gulp.src(files.spec)
.pipe(plumber({
errorHandler: function() {
this.emit('end');
}
}))
.pipe(ts())
.js
.pipe(gulp.dest(paths.spec))
.pipe(cover.instrument({
pattern: [files.dist],
}))
.pipe(jasmine())
.pipe(cover.report({
outFile: 'coverage.html'
}));
});
gulp.task('dev', function() {
gulp.watch(files.src, ['compile']);
gulp.watch([files.spec, files.dist], ['test']);
});
gulp.task('default', ['compile', 'test']);