-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
62 lines (49 loc) · 1.42 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
'use strict';
require('babel-polyfill');
var gulp = require('gulp');
var del = require('del');
var babel = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var merge = require('merge2');
var tsc = require('gulp-typescript');
var tslint = require('gulp-tslint');
var mocha = require('gulp-mocha');
var path = require('path');
var tsProject = tsc.createProject('tsconfig.json', {
typescript: require('typescript'),
noEmit: false,
declaration: true
});
gulp.task('clean', function() {
return del(path.join('lib', '.test'));
});
gulp.task('lint', function(){
return gulp.src(['src/**/*.ts', 'test/**/*.ts'])
.pipe(tslint())
.pipe(tslint.report('verbose'));
});
gulp.task('build', ['clean'], function() {
var stream = gulp.src(['src/*.ts'])
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return merge([
stream.dts.pipe(gulp.dest('lib')),
stream.js.pipe(babel())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'))
]);
});
gulp.task('test.build', ['build'], function() {
var stream = gulp.src(['test/*.spec.ts'])
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return stream.js.pipe(babel())
.pipe(sourcemaps.write('.test'))
.pipe(gulp.dest('.test'));
});
gulp.task('test', ['test.build'], function() {
return gulp.src(['.test/**/*.spec.js'])
.pipe(mocha());
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['lint', 'test']);