Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the module name inconsistent? #4

Open
pragdave opened this issue Feb 14, 2021 · 1 comment
Open

Is the module name inconsistent? #4

pragdave opened this issue Feb 14, 2021 · 1 comment

Comments

@pragdave
Copy link

pragdave commented Feb 14, 2021

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...

@pragdave
Copy link
Author

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);
   });
~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant