2015-10-14 10:31:06 +02:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var tsb = require('gulp-tsb');
|
|
|
|
var filter = require('gulp-filter');
|
|
|
|
var rimraf = require('rimraf');
|
2015-10-14 11:18:34 +02:00
|
|
|
var path = require('path');
|
2015-10-14 10:31:06 +02:00
|
|
|
var es = require('event-stream');
|
2015-11-17 21:53:32 +01:00
|
|
|
var cp = require('child_process');
|
2015-10-14 11:18:34 +02:00
|
|
|
var options = require('./tsconfig.json').compilerOptions;
|
2015-10-14 10:31:06 +02:00
|
|
|
|
2015-10-14 11:18:34 +02:00
|
|
|
options.sourceMap = true;
|
|
|
|
options.sourceRoot = path.join(__dirname, 'src');
|
|
|
|
|
|
|
|
var compilation = tsb.create(options);
|
2015-10-14 10:31:06 +02:00
|
|
|
|
2015-11-17 22:34:50 +01:00
|
|
|
function compile() {
|
2015-10-14 10:31:06 +02:00
|
|
|
var ts = filter('**/*.ts', { restore: true });
|
|
|
|
var input = es.merge(
|
2015-10-19 09:24:58 +02:00
|
|
|
gulp.src('src/**', { base: 'src', dot: true }),
|
2015-10-14 10:31:06 +02:00
|
|
|
gulp.src('typings/**/*.d.ts')
|
|
|
|
);
|
2015-11-25 10:23:21 +01:00
|
|
|
|
2015-10-14 10:31:06 +02:00
|
|
|
return input
|
|
|
|
.pipe(ts)
|
|
|
|
.pipe(compilation())
|
|
|
|
.pipe(ts.restore)
|
|
|
|
.pipe(gulp.dest('out'));
|
2015-11-17 22:34:50 +01:00
|
|
|
}
|
2015-10-14 10:31:06 +02:00
|
|
|
|
|
|
|
gulp.task('clean', function (cb) { rimraf('out', cb); });
|
|
|
|
gulp.task('compile', ['clean'], compile);
|
2015-11-17 22:34:50 +01:00
|
|
|
gulp.task('just-compile', compile);
|
2015-11-17 21:53:32 +01:00
|
|
|
|
2015-11-17 22:34:50 +01:00
|
|
|
function test(cb) {
|
|
|
|
var child = cp.spawn('mocha', [], { stdio: 'inherit' });
|
2015-11-17 21:53:32 +01:00
|
|
|
child.on('exit', function (code) { cb(); });
|
2015-11-17 22:34:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gulp.task('test', ['compile'], test);
|
|
|
|
gulp.task('just-test', ['just-compile'], test);
|
2015-11-17 21:53:32 +01:00
|
|
|
|
2016-01-28 20:04:53 +01:00
|
|
|
gulp.task('watch', ['compile'], function () {
|
|
|
|
gulp.watch(['src/**', 'typings/**'], ['just-compile']);
|
2015-11-17 21:53:32 +01:00
|
|
|
});
|
2015-11-25 10:23:21 +01:00
|
|
|
|
2016-06-01 11:06:17 +02:00
|
|
|
gulp.task('watch-test', ['compile'], function () {
|
|
|
|
gulp.watch(['src/**', 'typings/**'], ['just-test']);
|
|
|
|
});
|
|
|
|
|
2015-11-25 10:23:21 +01:00
|
|
|
gulp.task('default', ['watch']);
|