mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Fixing the repl so that errors print properly, and async exceptions are logged instead of killing the session.
This commit is contained in:
@@ -21,10 +21,13 @@
|
||||
console.log(val);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.stack || err.toString());
|
||||
stdio.write(err.stack || err.toString());
|
||||
}
|
||||
return repl.prompt();
|
||||
};
|
||||
process.on('uncaughtException', function(err) {
|
||||
return stdio.write(err.stack || err.toString());
|
||||
});
|
||||
repl = readline.createInterface(stdio);
|
||||
repl.setPrompt('coffee> ');
|
||||
stdio.on('data', function(buffer) {
|
||||
|
||||
@@ -23,9 +23,13 @@ run = (buffer) ->
|
||||
val = CoffeeScript.eval buffer.toString(), bare: on, globals: on, fileName: 'repl'
|
||||
console.log val if val isnt undefined
|
||||
catch err
|
||||
console.error err.stack or err.toString()
|
||||
stdio.write err.stack or err.toString()
|
||||
repl.prompt()
|
||||
|
||||
# Make sure that uncaught exceptions don't kill the REPL.
|
||||
process.on 'uncaughtException', (err) ->
|
||||
stdio.write err.stack or err.toString()
|
||||
|
||||
# Create the REPL by listening to **stdin**.
|
||||
repl = readline.createInterface stdio
|
||||
repl.setPrompt 'coffee> '
|
||||
|
||||
Reference in New Issue
Block a user