Created
June 2, 2016 13:06
-
-
Save drazisil/7c49ac781959f23fb36d1206ecd891da to your computer and use it in GitHub Desktop.
This file contains hidden or 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') | |
var standard = require('gulp-standard') | |
var mocha = require('gulp-mocha') | |
var istanbul = require('gulp-istanbul') | |
var coveralls = require('gulp-coveralls') | |
var output_path = process.cwd() | |
gulp.task('isCircle', function () { | |
if (process.env.CIRCLECI === 'true') { | |
console.log('Running on CircleCi, adjusting output path...') | |
output_path = process.env.CIRCLE_TEST_REPORTS | |
} | |
console.log('test output will be saved to : ' + output_path) | |
}) | |
gulp.task('standard', function () { | |
return gulp.src(['./index.js']) | |
.pipe(standard()) | |
.pipe(standard.reporter('default', { | |
breakOnError: true | |
})) | |
}) | |
gulp.task('pre-test', function () { | |
return gulp.src(['src/**/*.js']) | |
// Covering files | |
.pipe(istanbul()) | |
// Force `require` to return covered files | |
.pipe(istanbul.hookRequire()) | |
}) | |
gulp.task('test', ['pre-test'], function (cb) { | |
console.log('test output will be saved to : ' + output_path) | |
return gulp.src([ | |
'test/**/*.js' | |
]) | |
.pipe(mocha({ | |
reporter: 'mocha-junit-reporter', | |
reporterOptions: { | |
mochaFile: output_path + '/junit/results.xml' | |
} | |
})) | |
.pipe(istanbul.writeReports({ | |
dir: output_path + '/coverage' | |
})) // stores reports in "coverage" directory | |
}) | |
gulp.task('coveralls', ['test'], function (cb) { | |
return gulp.src(output_path + '/coverage/lcov.info') | |
.pipe(coveralls()) | |
}) | |
gulp.task('dev', ['isCircle', 'standard', 'coveralls']) | |
gulp.task('default', ['main']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment