ReasonML bindings for Node.js child_process module
npm i child-reprocess
then add it as a dependency to bsconfig.json
{
...
"bs-dependencies": ["child-reprocess"]
}
Module Structure:
ChildReprocess : the main module
StdStream : simple event-focused stream bindings
~option
objects are pure javascript objects (Js.t({..})
)
Event handlers are defined as separate functions. Example:
const cp = require("child_process")
let process = cp.spawn(
"youtube-dl",
["https://www.youtube.com/watch?v=15CXY6JAqbk"]
);
process.stdout.on(
"data",
chunk => console.log(String(chunk)),
);
is equivalent to:
open ChildReprocess.Util; /* <.> (functional composition) */
open ChildReprocess.StdStream; /* Readable */
let process =
ChildReprocess.spawn(
"youtube-dl",
[|"https://www.youtube.com/watch?v=15CXY6JAqbk"|],
(),
);
process
->child_stdout
->Readable.on_data(
Js.log <.> Node_buffer.toString
);
2310: syntax error, consider adding a `;' before