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
|
|
|
|
|
|
|
const ESLINT_SETTINGS = {
|
|
|
|
"env": {
|
|
|
|
"node": true,
|
|
|
|
"es6": true
|
|
|
|
},
|
|
|
|
"rules": {
|
|
|
|
"arrow-parens": [2, "as-needed"],
|
|
|
|
"no-console": [1],
|
|
|
|
"no-constant-condition": [1],
|
|
|
|
"no-extra-semi": [1],
|
|
|
|
"no-func-assign": [1],
|
2015-12-07 12:03:42 -05:00
|
|
|
"no-obj-calls": [2],
|
2015-12-03 20:43:42 -05:00
|
|
|
"no-unexpected-multiline" : [2],
|
2015-12-07 12:03:42 -05:00
|
|
|
"no-unneeded-ternary": [2],
|
2015-12-03 20:43:42 -05:00
|
|
|
"radix": [2],
|
|
|
|
"no-with": [2],
|
|
|
|
"no-eval": [2],
|
|
|
|
"no-unreachable": [1],
|
|
|
|
"no-irregular-whitespace": [1],
|
|
|
|
"no-new-wrappers": [2],
|
|
|
|
"no-new-func": [2],
|
|
|
|
"curly" : [2, "multi-line"],
|
|
|
|
"no-implied-eval": [2],
|
|
|
|
"no-invalid-this": [2],
|
|
|
|
"constructor-super": [2],
|
|
|
|
"no-dupe-args": [2],
|
|
|
|
"no-dupe-keys": [2],
|
|
|
|
"no-dupe-class-members": [2],
|
|
|
|
"no-this-before-super": [2],
|
|
|
|
"prefer-arrow-callback": [1],
|
|
|
|
"no-var": [2],
|
|
|
|
"valid-jsdoc": [1],
|
|
|
|
"strict": [2, "global"],
|
2015-12-07 12:03:42 -05:00
|
|
|
"callback-return": [1],
|
|
|
|
"object-shorthand": [1, "methods"],
|
|
|
|
"prefer-template": [1]
|
2015-12-03 20:43:42 -05:00
|
|
|
}
|
|
|
|
};
|
2015-12-02 13:01:31 -05:00
|
|
|
|
2015-12-03 20:43:42 -05:00
|
|
|
gulp.task('lint', () => {
|
2015-12-07 17:03:36 -05:00
|
|
|
pipe(gulp.src(SRC_FILES), [
|
2015-12-03 20:43:42 -05:00
|
|
|
eslint(ESLINT_SETTINGS),
|
|
|
|
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']), [
|
2015-12-03 20:43:42 -05:00
|
|
|
eslint(ESLINT_SETTINGS),
|
|
|
|
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', () => {
|
|
|
|
gulp.src('./lib/QueryBuilder.js')
|
2015-11-20 09:14:09 -05:00
|
|
|
.pipe(documentation({format: 'html'}))
|
|
|
|
.pipe(gulp.dest('docs'));
|
2015-12-02 13:01:31 -05:00
|
|
|
/*gulp.src('./lib/QueryBuilder.js')
|
2015-11-20 09:14:09 -05:00
|
|
|
.pipe(documentation({format: 'md'}))
|
2015-12-02 13:01:31 -05:00
|
|
|
.pipe(gulp.dest('api-docs'));*/
|
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)
|
|
|
|
.pipe(mocha({
|
|
|
|
ui: 'tdd',
|
|
|
|
bail: true,
|
2015-12-07 17:03:36 -05:00
|
|
|
reporter: 'list',
|
|
|
|
timeout: 5000
|
2015-12-07 12:03:42 -05:00
|
|
|
}))
|
|
|
|
.once('error', () => {
|
|
|
|
process.exit(1);
|
|
|
|
})
|
|
|
|
.once('end', () => {
|
|
|
|
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), [
|
|
|
|
mocha({
|
|
|
|
ui: 'tdd',
|
|
|
|
bail: true
|
|
|
|
}),
|
|
|
|
istanbul.writeReports({
|
|
|
|
dir: './coverage',
|
|
|
|
reporters: ['lcov', 'lcovonly', 'html', 'text']
|
|
|
|
})
|
2015-12-07 12:03:42 -05:00
|
|
|
.once('error', () => {
|
|
|
|
process.exit(1);
|
|
|
|
})
|
|
|
|
.once('end', () => {
|
|
|
|
process.exit();
|
|
|
|
})
|
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']);
|