Last active
March 3, 2018 08:22
-
-
Save asalant/4155716 to your computer and use it in GitHub Desktop.
CoffeeScript REPL using Node's REPL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
i found out you can customise the "completer" function but then you have to complete the "globals" as well...
sounds like a lot of work, but in a way a bit of fun.