Currently working with the node repl can be a bit cumbersome, this patch 
adds two features to the repl.

*noderc*

The first feature is a noderc. Upon startup in interactive mode, node will 
check for ~/.noderc.js and /present/working/directory/.noderc.js and if 
they exist, run them, and merge anything they export into the repl context. 
This allows someone to setup debugging or other utilities that they use a 
lot, both on a system level, and on a per project/directory level.

An example .noderc.js would be:

    function inspect(obj) {
      console.log(require('util').inspect(obj, true, 10, true));
    }

    exports.p = inspect;

so anywhere in your repl you could just do p(someobject) and have pretty 
output.


*node history*

The other feature is a node history. When the repl exits it will save the 
history (currently the last 100 lines) to ~/.node_history, and when 
started, it will check for that file and load any history if the file 
exists.




It's worth noting that this patch only effects node when started in 
interactive mode (run with -i or no arguments), and will not affect using 
the repl programmatically, other than there will be a few extra methods 
available (such as get/setHistory, loadContext). This is important because 
we don't want to introduce unexpected side effects to those who already use 
the repl.

Any thoughts, comments, and suggestions would be appreciated.

There is currently a pull request open for this feature: 
https://github.com/joyent/node/pull/3178

Reply via email to