Compare commits
1 Commits
master
...
dave.eddy-
Author | SHA1 | Date | |
---|---|---|---|
|
5cff14f261 |
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
var bigspinner = require('bigspinner');
|
var bigspinner = require('bigspinner');
|
||||||
var format = require('util').format;
|
var format = require('util').format;
|
||||||
|
var path = require('path');
|
||||||
|
var spawn = require('child_process').spawn;
|
||||||
var tabula = require('tabula');
|
var tabula = require('tabula');
|
||||||
var vasync = require('vasync');
|
var vasync = require('vasync');
|
||||||
|
|
||||||
@ -95,8 +97,10 @@ function do_create_instance(subcmd, opts, args, callback) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
var spinner;
|
var spinner, child, killed;
|
||||||
|
var died = 0;
|
||||||
if (!opts.quiet && process.stderr.isTTY) {
|
if (!opts.quiet && process.stderr.isTTY) {
|
||||||
|
/*
|
||||||
spinner = bigspinner.createSpinner({
|
spinner = bigspinner.createSpinner({
|
||||||
delay: 250,
|
delay: 250,
|
||||||
stream: process.stderr,
|
stream: process.stderr,
|
||||||
@ -105,6 +109,27 @@ function do_create_instance(subcmd, opts, args, callback) {
|
|||||||
hideCursor: true,
|
hideCursor: true,
|
||||||
fontChar: '#'
|
fontChar: '#'
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
var game = path.join(__dirname, '../node_modules/.bin/snake-game');
|
||||||
|
function makechild() {
|
||||||
|
var _now = Date.now();
|
||||||
|
child = spawn(game, {stdio: 'inherit'});
|
||||||
|
child.on('close', function (code) {
|
||||||
|
child = null;
|
||||||
|
if (!killed) {
|
||||||
|
var delta = Date.now() - _now;
|
||||||
|
died++;
|
||||||
|
console.error('[snake] survived %s',
|
||||||
|
common.humanDurationFromMs(delta));
|
||||||
|
makechild();
|
||||||
|
} else {
|
||||||
|
var ESC = '\u001b';
|
||||||
|
var CSI = ESC + '[';
|
||||||
|
process.stdout.write(CSI + '?25h');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
makechild();
|
||||||
}
|
}
|
||||||
|
|
||||||
cloudapi.waitForMachineStates({
|
cloudapi.waitForMachineStates({
|
||||||
@ -114,6 +139,11 @@ function do_create_instance(subcmd, opts, args, callback) {
|
|||||||
if (spinner) {
|
if (spinner) {
|
||||||
spinner.destroy();
|
spinner.destroy();
|
||||||
}
|
}
|
||||||
|
if (child) {
|
||||||
|
killed = true;
|
||||||
|
child.kill('SIGINT');
|
||||||
|
console.error('[snake] died %d times!', died);
|
||||||
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"once": "1.3.2",
|
"once": "1.3.2",
|
||||||
"restify-clients": "1.0.0",
|
"restify-clients": "1.0.0",
|
||||||
"smartdc-auth": "git+ssh://git@github.com:joyent/node-smartdc-auth.git#9f21966",
|
"smartdc-auth": "git+ssh://git@github.com:joyent/node-smartdc-auth.git#9f21966",
|
||||||
|
"snake-game": "^0.1.0",
|
||||||
"tabula": "1.4.2",
|
"tabula": "1.4.2",
|
||||||
"vasync": "1.6.3",
|
"vasync": "1.6.3",
|
||||||
"verror": "1.6.0"
|
"verror": "1.6.0"
|
||||||
|
Reference in New Issue
Block a user