Is the module name inconsistent?
pragdave opened this issue · comments
When I try to use this from Rescript, I get
Error: package name is expected to be bs-node-readline but got bs-readline
I'm new to all this, but I believe it's because the mopdule name is bsconfig
doesn't match the directory name (or the name in package.json)?
Major apologies if I just don't understand something obvious...
I changed the name in bsconfig
and it now works fine.
If you wanted to show your example as a Rescript version as well, it's a minor change:
let options =
Readline.interfaceOptions(
~input=%raw(`process.stdin`),
~output=%raw(`process.stdout`),
(),
);
let readline = Readline.createInterface(options);
let yes = %re("/yes|y/gi")
let no = %re("/no|n/gi")
readline
-> Readline.question("Is ReasonML and BuckleScript awesome? ", answer => {
switch (answer) {
| a when Js.Re.test_(a, yes) => print_endline("You know it!")
| a when Js.Re.test_(a, no) =>
print_endline("You need to revaluate your answer")
| _a =>
print_endline(`I don't have a variant for your answer 😦`)
};
Readline.close(readline);
});
~~~