-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (47 loc) · 1.69 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
gulpts = require('gulp-typescript'),
mocha = require('gulp-mocha'),
browserify = require('gulp-browserify');
//create a tsproject varible for running task buildsrc
var tsProjectSrc = gulpts.createProject('tsconfig.json');
//buildsrc ts files with typescript
gulp.task('buildsrc', function() {
var tsResult = gulp.src('./src/app/**/*.ts')
.pipe(tsProjectSrc());
return tsResult.js.pipe( gulp.dest('build/') )
// .on('end',function () { gulp.start('rununittest'); });
});
//watch src files and run buildsrc task
gulp.task('watchsrc', ['buildsrc'], function() {
gulp.watch('./src/app/**/*.ts', ['buildsrc']);
});
function handleError(err) {
console.log(err.toString());
this.emit('end');
}
//run unit tests with mocha
gulp.task('rununittest',['buildsrc'], function() {
return gulp.src(['./src/test/**/*.spec.js'], { read: false })
.pipe(mocha({ reporter: 'list' }))
.on('error', handleError);
});
//watch unit js files and run rununittest
gulp.task('watchtest_unit', ['rununittest'], function() {
gulp.watch('./src/test/**/*.spec.js', ['rununittest']);
});
//watch output image.js for browserify
gulp.task('watch_output', ['buildsrc'], function() {
// gulp.watch('build/image.js', ['runbrowserify']);
});
gulp.task('runbrowserify', function() {
// Single entry point to browserify
gulp.src('build/image.js')
.pipe(browserify({
insertGlobals : true,
debug : !gulp.env.production
}))
.pipe(gulp.dest('./build/browserify'))
});
//default tasks
gulp.task('default',['watchsrc','watchtest_unit','watch_output']);