forked from stimms/gulp-intern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (32 loc) · 1.03 KB
/
index.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
var through = require('through');
var spawn = require('child_process').spawn;
var gutil = require('gulp-util');
module.exports = function(opt) {
opt = opt || {};
opt.config = opt.config || "tests/config";
opt.workingDir = opt.workingDir || process.cwd();
function bufferContents(file) {
}
function endStream() {
var child = spawn("node", [process.cwd() + "\\node_modules\\intern\\bin\\intern-client.js", "config=" + opt.config], {cwd: opt.workingDir}),
stdout = '',
stderr = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function (data) {
stdout += data;
gutil.log(data);
});
child.stderr.setEncoding('utf8');
child.stderr.on('data', function (data) {
stderr += data;
gutil.log(gutil.colors.red(data));
gutil.beep();
});
child.on('close', function(code) {
if(code !== 0)
new gutil.PluginError("gulp-intern", "Tests failed");
});
this.emit('end');
}
return through(bufferContents, endStream);
}