Skip to content

Commit e2a0035

Browse files
committed
Add adventure binary
1 parent 8e3c589 commit e2a0035

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

bin/adventurejs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env node
2+
3+
/* eslint-disable no-console */
4+
var rl = require('readline');
5+
var advent = require("../src");
6+
7+
var app = advent.makeState();
8+
app.advance().forEach(_print);
9+
10+
var _input = rl.createInterface(process.stdin, process.stdout);
11+
_input.setPrompt('> ');
12+
_input.prompt();
13+
14+
_input.on('line', (l) => {
15+
16+
app.advance(l).forEach(_print);
17+
18+
if (app.isDone()) {
19+
process.exit(0);
20+
}
21+
22+
_input.prompt();
23+
});
24+
25+
function _print(line) {
26+
console.log(line);
27+
}

0 commit comments

Comments
 (0)