Skip to content

Instantly share code, notes, and snippets.

@bazo
Created April 9, 2014 21:15
Show Gist options
  • Save bazo/10317145 to your computer and use it in GitHub Desktop.
Save bazo/10317145 to your computer and use it in GitHub Desktop.
'use strict';
var gulp = require('gulp');
var typescript = require('gulp-tsc');
var mocha = require('gulp-mocha');
var growl = require('gulp-notify-growl');
var async = require('async');
var notify = growl();
var paths = {
typescript: ['src/**/*.ts'],
test: ['test/**/*.js'],
dest: 'app'
};
function compile() {
gulp.src(paths.typescript)
.pipe(typescript({sourcemap: true, emitError: false}))
.pipe(gulp.dest(paths.dest))
.on("error", notify.onError({
message: "Error: <%= error.message %>",
title: "Error compiling typescript"
}));
}
function test() {
gulp.src(paths.test)
.pipe(mocha({reporter: 'spec'}))
.on("error", notify.onError({
message: "Error: <%= error.message %>",
title: "Error running tests"
}));
}
gulp.task('compile', function () {
compile();
});
gulp.task('test', function () {
test();
});
gulp.task('compileAndTest', function () {
async.series([
compile(),
test()
]);
});
// Rerun the task when a file changes
gulp.task('watch', function () {
gulp.watch(paths.typescript, ['compileAndTest']);
gulp.watch(paths.test, ['test']);
});
gulp.task('default', ['compileAndTest', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment