Skip to content

Instantly share code, notes, and snippets.

@sspencer
Created April 10, 2013 19:52
Show Gist options
  • Save sspencer/5357871 to your computer and use it in GitHub Desktop.
Save sspencer/5357871 to your computer and use it in GitHub Desktop.
Simple standalone NodeJS REPL.
// Simple embedded REPL
var repl = require("repl");
repl.start({
prompt: "karma> ",
input: process.stdin,
output: process.stdout,
eval: function(cmd, context, filename, callback) {
// cmd comes thru as "(ls\n)", get back to original "ls"
callback("You typed: " + cmd.substring(1, cmd.length-1).trim());
},
writer: function(object) {
return String(object);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment