jbr / sibilant

Just another compile-to-js LISP-like language
https://sibilant.org
MIT License
386 stars 47 forks source link

Fix for require behavior in repl #97

Closed riatzukiza closed 4 years ago

riatzukiza commented 7 years ago

This fixes the issue where, whent he repl is open in say /home/foo/bar and there exists a module /home/foo/bar/bazzle or /home/foo/bar/node_modules/dingle, that it cannot find it.

the reason why this error was occuring was that when the repl loads, the require statement was using ./lib/ of the sibilant project folder as the start of the decendent search for packages.

This was corrected by modifying the module.path value that is passed to to the repl. I break up (process.cwd) and itterate over its parts, building the set of paths that node would usually start from given a repl at the cwd.

It may or may not be desired, that in this search, I still retain the original paths from ./lib/cli.js, so from with in the repl (and maybe the include statement), it would be possible to find packages located relative to ./lib of the sibilant project.

Also, this has not been tested, but I think that the issue of inclusion statements not properly searching through node_modules folders has also been resolved. #96 #