1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/elm/bootstrap.js
2017-06-08 19:19:27 +02:00

22 lines
626 B
JavaScript

var readline = require('./node_readline');
// The first two arguments are: 'node' and 'bootstrap.js'
// The third argument is the name of the Elm module to load.
var args = process.argv.slice(2);
var mod = require('./' + args[0]);
var app = mod.Main.worker({
args: args.slice(1)
});
// Hook up the writeLine and readLine ports of the app.
app.ports.writeLine.subscribe(function(line) {
console.log(line);
app.ports.input.send({"tag": "lineWritten"});
});
app.ports.readLine.subscribe(function(prompt) {
var line = readline.readline(prompt);
app.ports.input.send({"tag": "lineRead", "line": line});
});