-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (54 loc) · 1.46 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const shell = require('gulp-shell');
const runseq = require('run-sequence');
const tslint = require('gulp-tslint');
const { remove } = require('fs-extra');
const merge = require('merge2');
const sourcemaps = require('gulp-sourcemaps');
const tsProject = ts.createProject('tsconfig.json');
const mocha = require('gulp-mocha');
const releaseHelper = require('release-helper');
//TODO: Add releaseHelper.init(gulp); - once it works w/ gulp 4.0
gulp.task('clean', done => {
remove('./lib', done);
});
gulp.task('live-test', () => {
return gulp.src('test/**/*.js', { read: false })
.pipe(mocha())
.on('error', () => { });
});
gulp.task('test', (done) => {
return gulp.src('test/**/*.js', { read: false })
.pipe(mocha())
.once('error', (e) => {
done(e);
process.exit(1);
})
.once('end', () => {
done();
process.exit();
})
});
gulp.task('watch', () => {
return gulp.watch(
['src/**/*.ts', 'test/**/*.js'],
gulp.series('build', 'live-test'));
});
gulp.task('build', function () {
let tsResult = gulp.src('src/**/*.ts') // or tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
let js = tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('lib'));
let dts = tsResult.dts
.pipe(gulp.dest('lib'));
return merge([
js,
dts
]);
});
gulp.task('default', gulp.series('clean', 'build', (done) => {
done();
}));