mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
pretty node-like output in the REPL
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
(function() {
|
||||
var ACCESSOR, CoffeeScript, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, error, getCompletions, getPropertyNames, readline, repl, run, stdin, stdout;
|
||||
var ACCESSOR, CoffeeScript, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, error, getCompletions, getPropertyNames, inspect, readline, repl, run, stdin, stdout;
|
||||
var __hasProp = Object.prototype.hasOwnProperty;
|
||||
CoffeeScript = require('./coffee-script');
|
||||
readline = require('readline');
|
||||
inspect = require('util').inspect;
|
||||
Script = process.binding('evals').Script;
|
||||
stdin = process.openStdin();
|
||||
stdout = process.stdout;
|
||||
@@ -24,7 +25,7 @@
|
||||
filename: 'repl'
|
||||
});
|
||||
if (val !== void 0) {
|
||||
process.stdout.write(val + '\n');
|
||||
process.stdout.write(inspect(val, false, 2, true) + '\n');
|
||||
}
|
||||
} catch (err) {
|
||||
error(err);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# Require the **coffee-script** module to get access to the compiler.
|
||||
CoffeeScript = require './coffee-script'
|
||||
readline = require 'readline'
|
||||
{inspect} = require 'util'
|
||||
Script = process.binding('evals').Script
|
||||
|
||||
# REPL Setup
|
||||
@@ -32,7 +33,7 @@ run = (buffer) ->
|
||||
backlog = ''
|
||||
try
|
||||
val = CoffeeScript.eval code, bare: on, globals: on, filename: 'repl'
|
||||
process.stdout.write val + '\n' if val isnt undefined
|
||||
process.stdout.write inspect(val, no, 2, yes) + '\n' if val isnt undefined
|
||||
catch err
|
||||
error err
|
||||
repl.prompt()
|
||||
|
||||
Reference in New Issue
Block a user