Skip to content

Instantly share code, notes, and snippets.

@fiveisprime
Last active December 22, 2015 19:19
Show Gist options
  • Save fiveisprime/6518753 to your computer and use it in GitHub Desktop.
Save fiveisprime/6518753 to your computer and use it in GitHub Desktop.
Easy interaction with node.js REPL.
var local = require('repl').start('> ');
local.context.set = function(name) {
return function(err, value) {
if (err) throw err;
local.context[name] = value;
};
};
//
// Run in node to see a REPL prompt.
// Now do fun stuff like:
// > fs.readFile('repl.js', 'utf8', set('file'))
// undefined
// > console.log(file)
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment