This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
forked from clearhead/clearhead
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
77 lines (66 loc) · 1.82 KB
/
gulpfile.babel.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import gulp from 'gulp';
import babel from 'babel-register';
import babelify from 'babelify';
import through2 from 'through2';
import browserify from 'browserify';
import del from 'del';
import eslint from 'gulp-eslint';
import mocha from 'gulp-mocha';
import gulpSequence from 'gulp-sequence';
// import mochaPhantomJS from 'gulp-mocha-phantomjs';
var Server = require('karma').Server;
const sequence = gulpSequence.use(gulp);
gulp.task('default', sequence('lint', 'test'));
const babelConfig = {
jsxPragma: 'jsxr',
plugins: ['object-assign'],
};
// -- Lint ----------
gulp.task('lint', () => {
return gulp.src([
'./*.js',
'./src/**/*.js',
'./test/**/*.js',
'!./test/fixtures/lib/**/*.js',
]).pipe(eslint())
.pipe(eslint.format());
});
// -- Test ----------
gulp.task('test', ['test:modules', 'test:browser']);
gulp.task('test:modules', (done) => {
new Server({
configFile: __dirname + '/karma.conf.js',
}, done).start();
// return gulp.src(['./test/*.js'])
// .pipe(mocha({
// compilers: {
// js: babel(babelConfig),
// },
// }));
});
gulp.task('test:browser', sequence(
'test:clean-fixtures',
'test:compile-scripts'
// 'test:phantomjs'
));
gulp.task('test:clean-fixtures', () => {
del(['./test/fixtures/lib/*.js']);
});
gulp.task('test:compile-scripts', () => {
return gulp.src('./test/fixtures/src/*.js')
.pipe(through2.obj((file, enc, next) => {
browserify(file.path)
.transform(babelify.configure(babelConfig))
.bundle((err, res) => {
if (err) console.log(err);
file.contents = res;
next(null, file);
});
}))
.pipe(gulp.dest('./test/fixtures/lib/'));
});
// gulp.task('test:phantomjs', () => {
// return gulp
// .src('./test/*.html')
// .pipe(mochaPhantomJS());
// });