Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (39 sloc) 1.15 KB
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var child_process = require('child_process');
var async = require('async');
function getChildren(dir) {
var r = [];
if(arguments.length > 1) {
Array.prototype.slice.call(arguments, 0).forEach(function(dir) {
r = r.concat(getChildren(dir));
});
return r;
}
if(!fs.existsSync(dir)) return [];
if(fs.statSync(dir).isDirectory()) {
fs.readdirSync(dir).forEach(function(child) {
child = path.join(dir, child);
if(fs.statSync(child).isDirectory()) {
r = r.concat(getChildren(child));
} else r.push(child);
});
return r;
} else return [dir];
}
var args;
if(process.argv > 2) args = process.argv.slice(2);
else args = ['spec', 'test', 'test.js'];
var tests = getChildren.apply(null, args).filter(function(item) {
return path.extname(item) == '.js';
});
async.forEachSeries(tests, function(testfile, cb) {
console.log('\x1b[1;33m' + testfile + '\x1b[0m');
var child = child_process.spawn('node', [testfile]);
child.stderr.pipe(process.stderr);
child.stdout.pipe(process.stdout);
child.on('exit', function() {
cb();
});
});