UNPKG

ylog

Version:

Why another logger? That's a good question!

64 lines (54 loc) 1.64 kB
'use strict'; var gulp = require('gulp'); var plugins = require('gulp-load-plugins')(); var testFiles = ['./test/**/*.js', '!test/{temp,fixtures,temp/**,fixtures/**}']; var paths = { lint: ['./gulpfile.js', './src/**/*.js'], watch: ['./gulpfile.js', './src/**'].concat(testFiles), tests: testFiles, source: ['./src/**/*.js'] }; var plumberConf = {}; if (process.env.CI) { plumberConf.errorHandler = function(err) { throw err; }; } gulp.task('lint', function () { return gulp.src(paths.lint) .pipe(plugins.jshint('.jshintrc')) .pipe(plugins.plumber(plumberConf)) .pipe(plugins.jscs()) .pipe(plugins.jshint.reporter('jshint-stylish')); }); gulp.task('istanbul', function (cb) { gulp.src(paths.source) .pipe(plugins.istanbul()) // Covering files .pipe(plugins.istanbul.hookRequire()) // Force `require` to return covered files .on('finish', function () { gulp.src(paths.tests) .pipe(plugins.plumber(plumberConf)) .pipe(plugins.mocha()) .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned .on('finish', function() { process.chdir(__dirname); cb(); }); }); }); gulp.task('watch', ['test'], function () { gulp.watch(paths.watch, function() { // use child process, otherwise will get error. require('child_process').spawn('gulp', ['test'], { env: process.env, cwd: process.cwd(), stdio: [ process.stdin, process.stdout, process.stderr ] }); }); }); gulp.task('test', ['lint', 'istanbul']); gulp.task('default', ['watch']);