2015-12-03 20:43:42 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const documentation = require('gulp-documentation'),
|
2015-12-02 13:01:31 -05:00
|
|
|
eslint = require('gulp-eslint'),
|
|
|
|
gulp = require('gulp'),
|
2015-12-03 20:43:42 -05:00
|
|
|
istanbul = require('gulp-istanbul'),
|
2015-12-07 17:03:36 -05:00
|
|
|
jscs = require('gulp-jscs'),
|
2015-12-03 20:43:42 -05:00
|
|
|
mocha = require('gulp-mocha'),
|
|
|
|
pipe = require('gulp-pipe'),
|
|
|
|
sloc = require('gulp-sloc');
|
2015-11-20 09:14:09 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
const SRC_FILES = ['lib/**/*.js'];
|
2015-12-07 12:03:42 -05:00
|
|
|
const TEST_FILES = [
|
|
|
|
'test/*_test.js',
|
|
|
|
'test/adapters/*_test.js'
|
|
|
|
];
|
2015-12-03 20:43:42 -05:00
|
|
|
|
2016-01-26 19:29:12 -05:00
|
|
|
const MOCHA_OPTIONS = {
|
|
|
|
ui: 'tdd',
|
|
|
|
bail: true,
|
2016-01-26 20:34:35 -05:00
|
|
|
reporter: 'dot',
|
2016-01-26 19:29:12 -05:00
|
|
|
timeout: 10000,
|
|
|
|
};
|
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('lint', () => {
|
2015-12-07 17:03:36 -05:00
|
|
|
pipe(gulp.src(SRC_FILES), [
|
2016-03-11 13:29:01 -05:00
|
|
|
eslint(),
|
2015-12-03 20:43:42 -05:00
|
|
|
eslint.format(),
|
|
|
|
eslint.failAfterError()
|
|
|
|
]);
|
2015-12-07 17:03:36 -05:00
|
|
|
pipe(gulp.src(SRC_FILES), [
|
|
|
|
jscs(),
|
|
|
|
jscs.reporter()
|
|
|
|
]);
|
2015-12-02 13:01:31 -05:00
|
|
|
});
|
2015-11-20 09:14:09 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('lint-tests', ['lint'], () => {
|
2015-12-07 17:03:36 -05:00
|
|
|
pipe(gulp.src(['test/**/*.js']), [
|
2016-03-11 13:29:01 -05:00
|
|
|
eslint(),
|
2015-12-03 20:43:42 -05:00
|
|
|
eslint.format(),
|
|
|
|
eslint.failAfterError()
|
|
|
|
]);
|
2015-12-07 17:03:36 -05:00
|
|
|
pipe(gulp.src(['test/**/*.js']), [
|
|
|
|
jscs(),
|
|
|
|
jscs.reporter()
|
|
|
|
]);
|
2015-12-02 13:01:31 -05:00
|
|
|
});
|
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('sloc', () => gulp.src(SRC_FILES).pipe(sloc()));
|
|
|
|
gulp.task('test-sloc', () => gulp.src(TEST_FILES).pipe(sloc()));
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('docs', () => {
|
2016-02-10 13:09:06 -05:00
|
|
|
gulp.src(['lib/*.js'])
|
2015-11-20 09:14:09 -05:00
|
|
|
.pipe(documentation({format: 'html'}))
|
|
|
|
.pipe(gulp.dest('docs'));
|
2016-01-26 20:23:52 -05:00
|
|
|
gulp.src(['lib/*.js'])
|
|
|
|
.pipe(documentation({format: 'md'}))
|
|
|
|
.pipe(gulp.dest('.'));
|
2015-11-20 09:14:09 -05:00
|
|
|
});
|
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('mocha', ['lint-tests', 'sloc'], () => {
|
|
|
|
return gulp.src(TEST_FILES)
|
2016-01-26 19:29:12 -05:00
|
|
|
.pipe(mocha(MOCHA_OPTIONS))
|
2015-12-07 12:03:42 -05:00
|
|
|
.once('error', () => {
|
2016-03-11 16:32:38 -05:00
|
|
|
process.exit(1);
|
|
|
|
})
|
2015-12-07 12:03:42 -05:00
|
|
|
.once('end', () => {
|
2016-03-11 16:32:38 -05:00
|
|
|
process.exit();
|
|
|
|
});
|
2015-12-02 13:01:31 -05:00
|
|
|
});
|
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('test', ['test-sloc', 'lint-tests'], function(cb) {
|
|
|
|
return pipe(gulp.src(SRC_FILES), [
|
|
|
|
istanbul(),
|
|
|
|
istanbul.hookRequire()
|
|
|
|
]).on('finish', () => {
|
|
|
|
pipe(gulp.src(TEST_FILES), [
|
2016-01-26 19:29:12 -05:00
|
|
|
mocha(MOCHA_OPTIONS),
|
2015-12-03 20:43:42 -05:00
|
|
|
istanbul.writeReports({
|
|
|
|
dir: './coverage',
|
2016-03-11 16:32:38 -05:00
|
|
|
reporters: ['clover', 'lcov', 'lcovonly', 'html', 'text'],
|
|
|
|
}),
|
2015-12-03 20:43:42 -05:00
|
|
|
]);
|
|
|
|
});
|
2015-11-20 09:14:09 -05:00
|
|
|
});
|
|
|
|
|
2015-12-02 13:01:31 -05:00
|
|
|
gulp.task('default', ['lint', 'sloc', 'docs', 'test']);
|