This repository has been archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
69 lines (56 loc) · 1.58 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
60
61
62
63
64
65
66
67
68
69
'use strict';
const gulp = require('gulp');
// Are we running within continuous integration?
const CI = process.env.CI === 'true';
// File globs.
const entrypoint = require('./package.json')['main'];
const globs = {
sources: [entrypoint, 'lib/**/*.js'],
tests: ['test/**/*.test.js'],
testsSetup: ['./test/setup.js']
};
const all = Array.prototype.concat.apply([], Object.keys(globs).map(x => globs[x]));
// Default meta-task.
gulp.task('default', ['test']);
// Test meta-task.
const runSequence = require('run-sequence').use(gulp);
const noStack = function (done) {
return function (err) {
if (err) {
err.showStack = false;
done(err);
} else {
done();
}
};
};
gulp.task('test', function (done) {
runSequence('semistandard-lint', 'mocha-test', noStack(done));
});
// Watch meta-task.
const watch = require('gulp-watch');
const batch = require('gulp-batch');
gulp.task('watch', function () {
watch(all, { ignoreInitial: false }, batch(function (events, done) {
gulp.start('test', done);
}));
});
// Semistandard-based linting task.
const semistandard = require('gulp-semistandard');
gulp.task('semistandard-lint', function () {
return gulp.src(all.concat('./gulpfile.js'))
.pipe(semistandard())
.pipe(semistandard.reporter('default', {
breakOnError: true,
quiet: true
}));
});
// Mocha-based testing task.
const mocha = require('gulp-mocha');
gulp.task('mocha-test', function () {
return gulp.src(globs.tests, { read: false })
.pipe(mocha({
require: globs.testsSetup,
reporter: CI ? 'spec' : 'nyan'
}));
});