Skip to content

Instantly share code, notes, and snippets.

@freefrancisco
Forked from asalant/coffee-repl.js
Created March 3, 2018 08:22
Show Gist options
  • Save freefrancisco/2526d3d8344d65e1429e6cd7a3017954 to your computer and use it in GitHub Desktop.
Save freefrancisco/2526d3d8344d65e1429e6cd7a3017954 to your computer and use it in GitHub Desktop.
CoffeeScript REPL using Node's REPL
#!/usr/bin/env node
var vm = require('vm');
var repl = require('repl');
var CoffeeScript = require('coffee-script');
repl.start({
prompt: "coffee> ",
eval: function(code, context, file, cb) {
try {
code = CoffeeScript.compile(code, {filename: file, bare: true});
cb(null, vm.runInContext(code, context, file));
}
catch (err) {
cb(err);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment