forked from chartjs/chartjs-adapter-luxon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (49 loc) · 1.39 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
'use strict';
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var { exec } = require('child_process');
var karma = require('karma');
var path = require('path');
var argv = require('yargs')
.option('output', { alias: 'o', default: 'dist' })
.argv;
function run(bin, args, done) {
var exe = '"' + process.execPath + '"';
var src = require.resolve(bin);
var ps = exec([exe, src].concat(args || []).join(' '));
ps.stdout.pipe(process.stdout);
ps.stderr.pipe(process.stderr);
ps.on('close', () => done());
}
gulp.task('build', function(done) {
run('rollup/dist/bin/rollup', ['-c', argv.watch ? '--watch' : ''], done);
});
gulp.task('test-unit', function(done) {
new karma.Server({
configFile: path.join(__dirname, 'karma.config.js'),
singleRun: !argv.watch,
args: {
coverage: !!argv.coverage,
inputs: (argv.inputs || 'test/specs/**/*.js').split(';'),
watch: argv.watch
}
},
function(error) {
// https://github.com/karma-runner/gulp-karma/issues/18
error = error ? new Error('Karma returned with the error code: ' + error) : undefined;
done(error);
}).start();
});
gulp.task('lint', function() {
var files = [
'src/**/*.js',
'test/**/*.js',
'*.js'
];
return gulp.src(files)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('check', gulp.parallel('lint', 'test-unit'));
gulp.task('default', gulp.parallel('build'));