-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
var log = require('./log'), | ||
Stack = require('./stack').Stack, | ||
timer = require('./timer'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
spawn = require('child_process').spawn, | ||
exists = fs.exists || path.exists; | ||
|
||
exports.run = function() { | ||
log.info('racing the directories'); | ||
var modStack = new Stack(), | ||
start = new Date(), | ||
mods = []; | ||
|
||
fs.readdir(process.cwd(), modStack.add(function(err, dirs) { | ||
dirs.forEach(function(mod) { | ||
var p = path.join(process.cwd(), mod); | ||
exists(path.join(p, 'build.json'), modStack.add(function(yes) { | ||
if (yes) { | ||
mods.push(mod); | ||
} else { | ||
exists(path.join(p, 'build.xml'), modStack.add(function(yes) { | ||
if (yes) { | ||
mods.push(mod); | ||
} | ||
})); | ||
} | ||
})); | ||
}); | ||
})); | ||
|
||
modStack.done(function() { | ||
if (!mods.length) { | ||
log.error('no modules found, hitting the brakes.'); | ||
} | ||
log.info('found ' + mods.length + ' modules to race, let\'s do this'); | ||
log.warn('this will be quiet, only status will be emitted for speed. failed builds will print after'); | ||
var stack = new Stack(), | ||
errors = []; | ||
|
||
var run = function() { | ||
var mod = mods.pop(); | ||
if (mod) { | ||
var child = spawn('shifter', [], { | ||
cwd: path.join(process.cwd(), mod), | ||
stdio: ['ignore', 'ignore', process.stderr] | ||
}); | ||
child.on('exit', stack.add(function(code) { | ||
process.stdout.write((code ? '!'.red : '.'.white)); | ||
if (code) { | ||
errors.push(mod); | ||
} | ||
run(); | ||
})); | ||
} | ||
}; | ||
|
||
run(); | ||
|
||
stack.done(function() { | ||
console.log(''); | ||
var end = new Date(); | ||
log.info('done racing, the gears are toast'); | ||
log.info('finished in ' + timer.calc(start, end) + ', pretty fast huh?'); | ||
if (errors.length) { | ||
log.warn('the following builds exited with a 1'); | ||
console.log(errors.join(', ')); | ||
} | ||
}); | ||
}); | ||
}; |