light refactor for repl.coffee
This commit is contained in:
parent
879b3d76bd
commit
28a8c05513
|
@ -3,7 +3,6 @@
|
|||
// A CoffeeScript port/version of the Node.js REPL.
|
||||
// Required modules.
|
||||
coffee = require('coffee-script');
|
||||
process.mixin(require('sys'));
|
||||
// Shortcut variables.
|
||||
prompt = 'coffee> ';
|
||||
quit = function quit() {
|
||||
|
@ -12,13 +11,12 @@
|
|||
// The main REPL function. Called everytime a line of code is entered.
|
||||
// Attempt to evaluate the command. If there's an exception, print it.
|
||||
readline = function readline(code) {
|
||||
var js, val;
|
||||
var val;
|
||||
try {
|
||||
js = coffee.compile(code, {
|
||||
val = eval(coffee.compile(code, {
|
||||
no_wrap: true,
|
||||
globals: true
|
||||
});
|
||||
val = eval(js);
|
||||
}));
|
||||
if (val !== undefined) {
|
||||
p(val);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
# Required modules.
|
||||
coffee: require 'coffee-script'
|
||||
process.mixin require 'sys'
|
||||
|
||||
# Shortcut variables.
|
||||
prompt: 'coffee> '
|
||||
|
@ -12,8 +11,7 @@ quit: -> process.exit(0)
|
|||
# Attempt to evaluate the command. If there's an exception, print it.
|
||||
readline: (code) ->
|
||||
try
|
||||
js: coffee.compile code, {no_wrap: true, globals: true}
|
||||
val: eval(js)
|
||||
val: eval coffee.compile code, {no_wrap: true, globals: true}
|
||||
p val if val isnt undefined
|
||||
catch err
|
||||
puts err.stack or err.toString()
|
||||
|
|
Loading…
Reference in New Issue