forked from hwndept/node-seed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (69 loc) · 2.04 KB
/
gulpfile.js
File metadata and controls
80 lines (69 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var jsdoc = require('gulp-jsdoc');
var sequence = require('run-sequence');
var babel = require('gulp-babel');
var isparta = require('isparta');
var babelRegister = require('babel/register');
var GULP_FILE = ['gulpfile.js'];
var SRC_FILES = ['src/**/*.js'];
var TEST_FILES = ['test/**/*.js'];
var TEST_CASE_FILES = ['test/**/*.test.js'];
var COVERAGE_REPORT_DIR = 'build/coverage';
var COMPILED_SRC_DIR = 'build/source';
var COMPILED_SRC_FILES = [COMPILED_SRC_DIR + '/**/*.js'];
var JSDOC_DIR = 'build/jsdoc';
gulp.task('jshint', function (done) {
gulp.src(GULP_FILE.concat(SRC_FILES, TEST_FILES))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
.on('finish', done);
});
gulp.task('jscs', function (done) {
gulp.src(GULP_FILE.concat(SRC_FILES, TEST_FILES))
.pipe(jscs())
.on('finish', done);
});
gulp.task('test', function (done) {
gulp.src(SRC_FILES)
.pipe(istanbul({
instrumenter: isparta.Instrumenter,
includeUntested: true
}))
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(TEST_CASE_FILES)
.pipe(mocha({compilers: {js: babelRegister}}))
.pipe(istanbul.writeReports({
dir: COVERAGE_REPORT_DIR
}))
.pipe(istanbul.enforceThresholds({
thresholds: {
global: 100
}
}))
.on('finish', done);
});
});
gulp.task('compile', function (done) {
gulp.src(SRC_FILES)
.pipe(babel())
.pipe(gulp.dest(COMPILED_SRC_DIR))
.on('finish', done);
});
gulp.task('jsdoc', ['compile'], function (done) {
gulp.src(COMPILED_SRC_FILES)
.pipe(jsdoc(JSDOC_DIR))
.on('finish', done);
});
gulp.task('build', function (done) {
sequence('jshint', 'jscs', 'test', 'compile', 'jsdoc', done);
});
gulp.task('pre-commit', ['build']);
gulp.task('ci', ['build']);
gulp.task('default', ['build']);