Last active
June 9, 2016 05:51
-
-
Save ChrLipp/4c87f98dca8d859f16da3b87b483f0de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'), | |
del = require('del'), | |
tslint = require('gulp-tslint'), | |
typescript = require('gulp-typescript'), | |
babel = require('gulp-babel'), | |
sourcemaps = require('gulp-sourcemaps'), | |
mocha = require('gulp-mocha'), | |
istanbul = require('gulp-istanbul'), | |
remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul'), | |
config = require('./gulp.config')(); | |
// lint for code in source and test | |
gulp.task('lint', function doLint() { | |
return gulp.src([ | |
config.paths.sourcePattern, | |
config.paths.testPattern | |
]) | |
.pipe(tslint()) | |
.pipe(tslint.report('verbose', { | |
emitError: false, | |
summarizeFailureOutput: true | |
})); | |
}); | |
// build for code in source and test | |
var tsProject = typescript.createProject('tsconfig.json'); | |
gulp.task('build-app', gulp.series('lint', function doBuildApp() { | |
return gulp | |
.src([ | |
config.paths.sourcePattern, | |
'typings/index.d.ts' | |
]) | |
.pipe(sourcemaps.init()) | |
.pipe(typescript(tsProject)) | |
.pipe(babel({presets: ['es2015-node4']})) | |
.pipe(sourcemaps.write('.', { | |
sourceRoot: config.paths.sourceDir | |
})) | |
.pipe(gulp.dest(config.paths.outSourceDir)); | |
})); | |
gulp.task('build-test', function doBuildTest() { | |
return gulp | |
.src([ | |
config.paths.testPattern, | |
'source/model/jira-typings.ts', | |
'typings/index.d.ts' | |
]) | |
.pipe(sourcemaps.init()) | |
.pipe(typescript(tsProject)) | |
.pipe(babel({presets: ['es2015-node4']})) | |
.pipe(sourcemaps.write('.', { | |
sourceRoot: config.paths.testDir | |
})) | |
.pipe(gulp.dest(config.paths.outTestDir)); | |
}); | |
gulp.task('build', gulp.series('build-app', 'build-test')); | |
// run our unit tests | |
gulp.task('test', gulp.series( | |
function doPreTest() { | |
return gulp | |
.src([config.paths.outSourcePattern]) | |
.pipe(istanbul()) | |
.pipe(istanbul.hookRequire()); | |
}, function doTest() { | |
return gulp | |
.src(config.paths.outTestPattern) | |
.pipe(mocha({ | |
ui: 'bdd', | |
timeout: 10000 | |
})) | |
.pipe(istanbul.writeReports({ | |
dir: config.paths.outCoverageDir + 'js-json', | |
reporters: [ 'json'], | |
})); | |
}, function doPostTest() { | |
return gulp | |
.src(config.paths.outCoverageDir + 'js-json/coverage-final.json') | |
.pipe(remapIstanbul({ | |
reports: { | |
'json' : config.paths.outCoverageDir + 'ts-json/coverage.json', | |
'html' : config.paths.outCoverageDir + 'html-report', | |
'text-summary' : '' | |
} | |
})); | |
})); | |
// watcher | |
gulp.task('watch', gulp.series('test', function doWatch() { | |
gulp.watch([ | |
config.paths.sourcePattern, | |
config.paths.testPattern, | |
'gulpfile.js' | |
], gulp.series('test')); | |
})); | |
// clean build directory | |
gulp.task('clean', function doClean() { | |
return del([config.paths.outDir + '**/*']); | |
}); | |
// define default task | |
gulp.task('default', gulp.series('clean', 'test')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment