sikanhe / reason-nodejs

Node bindings for Reason and Bucklescript
MIT License
100 stars 18 forks source link

Fix Process.cwd #28

Closed fahmiirsyadk closed 4 years ago

fahmiirsyadk commented 4 years ago

Fix process.cwd returning function instead of string.

should be

i also create the test.

thank you for the work you have done on this project .

fahmiirsyadk commented 4 years ago

Sry, I do not know if there is a beta version. in beta, this bug did not happen. i'm gonna using the beta version.

Screen Shot 2020-05-09 at 08 56 41

austindd commented 4 years ago

@fahmiirsyadk Did you figure out the issue with this?

In some of the earlier versions, the Process module worked a lot like Node's built-in process object that you can import. So each function assumed that specific global instance of process.

In later versions (including the current beta), the JS process object must be provided to these functions for them to work. This is due to the fact that Node will allow you to provide different process objects to different contexts (such as a VM or worker thread), and so it makes sense to let it be a normal value, rather than always assume the globally imported instance.

P.S. The same is true of the Console module, for the same reasons. Console.console is the global default instance of console in JS, but it is possible to create new console instances, so we make sure that the functions will work on those new instances as well.