Skip to content

Instantly share code, notes, and snippets.

@superherointj
Created December 13, 2017 16:10
Show Gist options
  • Save superherointj/4dbe58b4ffdeff53737308f46f4fcc97 to your computer and use it in GitHub Desktop.
Save superherointj/4dbe58b4ffdeff53737308f46f4fcc97 to your computer and use it in GitHub Desktop.
App for testing Merlin protocol
// The goal here is to print Merlin version 3 times. To test sync/async support.
const { spawn } = require("child_process");
const mp = spawn("ocamlmerlin");
let i = 0;
mp.stdin.write('["protocol","version"]');
mp.stdout.on("data", data => {
console.log(`stdout: -----START -----\n${data}---------------------`);
if (i < 2) {
mp.stdin.write('["protocol","version"]');
i++;
}
});
mp.stderr.on("data", data => {
console.log(`stderr: ${data}`);
});
mp.on("close", code => {
console.log(`child process exited with code ${code}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment