Skip to content

Commit

Permalink
streadm-adventure run command
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jun 21, 2013
1 parent 38faf7d commit 3fa1ffd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var showMenu = require('./menu.js');
var verify = require('./verify.js');
var order = require('../data/order.json');

if (argv._[0] === 'verify') {
if (argv._[0] === 'verify' || argv._[0] === 'run') {
var current = getData('current');
if (!current) {
console.error('ERROR: No active problem. '
Expand All @@ -20,7 +20,12 @@ if (argv._[0] === 'verify') {
setTimeout(function () {
var a = [ argv._[1] ].concat(setup.args || []);
var b = [ dir + '/solution.js' ].concat(setup.args || []);
var v = verify(a, b, { a: setup.a, b: setup.b, long: setup.long });
var v = verify(a, b, {
a: setup.a,
b: setup.b,
long: setup.long,
run: argv._[0] === 'run'
});
v.on('pass', onpass);
v.on('fail', onfail);

Expand Down
5 changes: 5 additions & 0 deletions bin/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ COLORS.RESET = '\x1b[00m';
module.exports = function (acmd, bcmd, opts) {
if (!opts) opts = {};
var a = spawn(process.execPath, acmd);
if (opts.run) {
(opts.a || a.stdout).pipe(process.stdout);
return opts.a || a.stdin;
}

var b = spawn(process.execPath, bcmd);
var c = compare(opts.a || a.stdout, opts.b || b.stdout, opts);

Expand Down
3 changes: 2 additions & 1 deletion data/order.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"LINES",
"HTTP SERVER",
"HTTP CLIENT",
"CRYPT"
"CRYPT",
"SECRETZ"
]

0 comments on commit 3fa1ffd

Please sign in to comment.