-
Notifications
You must be signed in to change notification settings - Fork 12
/
Gulpfile.js
72 lines (55 loc) · 1.67 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
70
71
72
'use strict';
const { spawn } = require('child_process');
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha-simple');
function lint () {
return gulp
.src([
'generators/app/index.js',
'test/test.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function testContent () {
return gulp
.src('test/test.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 20000 : Infinity // NOTE: disable timeouts in debug
}));
}
function exitDomains () {
const domains = [];
while (process.domain) {
domains.push(process.domain);
process.domain.exit();
}
return domains;
}
function enterDomains (domains) {
let domain = domains.pop();
while (domain) {
domain.enter();
domain = domains.pop();
}
}
async function createExampleReporter () {
// HACK: We have to exit from all Gulp's error domains to avoid conflicts
// with error handling inside yeoman-test helpers.
const domains = exitDomains();
const { createReporter } = require('./test/util');
await createReporter();
enterDomains(domains);
}
function testExample () {
return spawn('npx gulp generateTestData && npx gulp test', { stdio: 'inherit', shell: true });
}
exports.lint = lint;
exports.testContent = testContent;
exports.testExample = gulp.series(createExampleReporter, testExample);
exports.test = gulp.series(lint, testContent, exports.testExample);