JohnEarnest / ok

An open-source interpreter for the K5 programming language.
MIT License
587 stars 72 forks source link

Add support for running rc file on REPL startup #43

Closed FireyFly closed 8 years ago

FireyFly commented 8 years ago

Runs ~/.config/okrc.k on startup of repl.js if it exists (otherwise it is ignored). This was prompted by me recently experimenting with K5 using oK, and then wanting to save some utility functions for re-use later. I could put them in a file and just copy-paste as necessary, but it would be even nicer if I could put them in a file that gets sourced automatically on REPL startup.

The reliance on exception handling to see if the file exists is a bit.. crude and ugly to me, but it seems to be the recommended approach: https://nodejs.org/api/fs.html#fs_fs_exists_path_callback