Skip to content

Commit

Permalink
Merge branch 'master' of github.com:busterjs/buster
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Johansen committed Feb 13, 2012
2 parents f999a38 + d85f709 commit 322e3df
Showing 1 changed file with 54 additions and 26 deletions.
80 changes: 54 additions & 26 deletions bin/buster
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,62 @@ var fs = require("fs");
var childProcess = require("child_process");

var argv = Array.prototype.slice.call(process.argv).slice(2)
var cmd = argv.shift();

var cmdExists = childProcess.exec(
"command -v buster-" + cmd,
{env: process.env},
function (error, stdout, stderr) {
if (error) {
if (error.code == 1) {
console.log("Buster command '" + cmd + "' does not exist.");

if (argv.length == 0 || argv[0] == "--help" || argv[0] == "-h") {
printHelp();
} else if (argv[0] == "--version" || argv[0] == "-v") {
printVersions();
} else {
var cmd = argv.shift();
if (/^\-/.test(cmd)) {
console.log("Unknown option " + cmd + ", try buster --help.");
} else {
runBusterCmd(cmd);
}
}

function printHelp() {
console.log("Usage: buster [--version,-v] <command> [<args>]");
console.log();
console.log("The most commonly used Buster.JS commands are:");
console.log(" test Run tests with Buster.JS");
console.log(" server Manually start the server for browser capturing");
console.log(" autotest Like 'test', but automatically re-run tests when files change");
console.log(" static An alternative static HTML page based runner");
}

function printVersions() {
console.log("Buster.JS version 0.3 beta1");
}

function runBusterCmd() {
childProcess.exec(
"command -v buster-" + cmd,
{env: process.env},
function (error, stdout, stderr) {
if (error) {
if (error.code == 1) {
console.log("Buster command '" + cmd + "' does not exist.");
} else {
console.log("Unknown error occurred when running wrapper script.");
console.log("Try using buster-server, buster-test etc directly.");
}
} else {
console.log("Unknown error occurred when running wrapper script.");
console.log("Try using buster-server, buster-test etc directly.");
}
} else {
var mod = stdout.split("\n")[0];
var mod = stdout.split("\n")[0];

var run = childProcess.spawn(mod, argv, {env: process.env, setsid: true});
run.stdout.on('data', function (data) {
process.stdout.write(data);
});
var run = childProcess.spawn(mod, argv, {env: process.env, setsid: true});
run.stdout.on('data', function (data) {
process.stdout.write(data);
});

run.stderr.on('data', function (data) {
process.stderr.write(data);
});
run.stderr.on('data', function (data) {
process.stderr.write(data);
});

run.on('exit', function (code) {
process.exit(code);
});
run.on('exit', function (code) {
process.exit(code);
});
}
}
}
);
);
}

0 comments on commit 322e3df

Please sign in to comment.