Last active
August 29, 2015 14:27
-
-
Save yeghishe/c6f3171a6ec9db89134c to your computer and use it in GitHub Desktop.
Gulp file for library projects in coffeescript
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
gulp = require 'gulp' | |
del = require 'del' | |
$ = require('gulp-load-plugins') lazy: false | |
paths = | |
coffeeFiles: './src/**/*.coffee' | |
specFiles: 'test/**/*.spec.coffee' | |
codeFiles: ['./src/**/*.coffee', 'test/**/*.spec.coffee'] | |
libDir: './lib/' | |
buildDir: './build/' | |
gulp.task 'version', -> | |
console.log require('./package.json').version | |
gulp.task 'clean', (cb) -> | |
del [paths.buildDir], cb | |
gulp.task 'lint', -> | |
is_jenkins = process.env.JENKINS is 'true' | |
gulp.src paths.coffeeFiles | |
.pipe $.coffeelint() | |
.pipe $.coffeelint.reporter( | |
if is_jenkins then 'checkstyle' else 'coffeelint-stylish' | |
) | |
.pipe $.coffee(bare: false).on('error', $.util.log) | |
.pipe $.jshint('.jshintrc') | |
.pipe( | |
if is_jenkins | |
$.jshint.reporter('gulp-checkstyle-jenkins-reporter', filename: paths.buildDir + 'checkstyle-result.xml') | |
else | |
$.jshint.reporter('jshint-stylish') | |
) | |
gulp.task 'test', -> | |
gulp.src paths.coffeeFiles | |
.pipe $.coffeeIstanbul includeUntested: true | |
.pipe $.coffeeIstanbul.hookRequire() | |
.on 'finish', -> | |
gulp.src paths.specFiles | |
.pipe $.mocha reporter: 'mocha-jenkins-reporter', compilers: 'coffee:coffee-script' | |
.pipe $.coffeeIstanbul.writeReports dir: paths.buildDir + 'coverage', reporters: ['cobertura', 'lcov', 'text'] | |
gulp.task 'compile', -> | |
gulp.src paths.coffeeFiles | |
.pipe $.coffee(bare: false).on('error', $.util.log) | |
.pipe gulp.dest paths.libDir | |
gulp.task 'watch', -> | |
gulp.watch paths.codeFiles, gulp.series('build') | |
gulp.task 'build', gulp.series('clean', 'lint', 'test', 'compile') | |
gulp.task 'default', gulp.series('build', 'watch') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment