-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
59 lines (51 loc) · 1.32 KB
/
gulpfile.js
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
/* eslint-disable */
'use strict';
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const fs = require('fs');
const mocha = require('gulp-mocha');
const path = require('path');
const babel = require('gulp-babel');
const runSequence = require('run-sequence');
require('babel-core/register');
gulp.task('lint', () => {
let _eslintFormat = eslint.format();
if (process.env.NODE_ENV === 'test') {
_eslintFormat = eslint.format('junit', results => {
fs.writeFileSync(path.join(process.env.CIRCLE_TEST_REPORTS, 'eslint.xml'), results);
});
}
return gulp.src(['src/**/*.js', '!node_modules/**'])
.pipe(eslint())
.pipe(_eslintFormat)
.pipe(eslint.failAfterError());
});
gulp.task('run', ['build'], () => {
return gulpNpmCheck();
});
gulp.task('unit-test', () => {
let _mocha = mocha();
if (process.env.NODE_ENV === 'test') {
_mocha = mocha({
reporter: 'mocha-junit-reporter',
reporterOptions: {
mochaFile: path.join(process.env.CIRCLE_TEST_REPORTS, 'mocha.xml')
}
});
}
return gulp.src('test/test.js', {
read: false
})
.pipe(_mocha);
});
gulp.task('build', () => {
return gulp.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('test', () => {
runSequence(['build'],
'lint',
'unit-test'
);
});