mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 09:17:55 -05:00
Add backwards compatibility for older readline
Check the readline.createInterface for arity. If it is 3, assume the newer interface requiring separate stdin and stdout. Otherwise, use the older calling style.
This commit is contained in:
@@ -78,7 +78,14 @@
|
||||
return _results;
|
||||
};
|
||||
process.on('uncaughtException', error);
|
||||
repl = readline.createInterface(stdin, stdout, autocomplete);
|
||||
if (readline.createInterface.length === 3) {
|
||||
repl = readline.createInterface(stdin, stdout, autocomplete);
|
||||
} else {
|
||||
repl = readline.createInterface(stdin, autocomplete);
|
||||
stdin.on('data', function(buffer) {
|
||||
return repl.write(buffer);
|
||||
});
|
||||
}
|
||||
repl.setPrompt('coffee> ');
|
||||
repl.on('close', function() {
|
||||
return stdin.destroy();
|
||||
|
||||
@@ -77,7 +77,12 @@ getPropertyNames = (obj) ->
|
||||
process.on 'uncaughtException', error
|
||||
|
||||
# Create the REPL by listening to **stdin**.
|
||||
repl = readline.createInterface stdin, stdout, autocomplete
|
||||
if readline.createInterface.length == 3
|
||||
repl = readline.createInterface stdin, stdout, autocomplete
|
||||
else
|
||||
repl = readline.createInterface stdin, autocomplete
|
||||
stdin.on 'data', (buffer) -> repl.write buffer
|
||||
|
||||
repl.setPrompt 'coffee> '
|
||||
repl.on 'close', -> stdin.destroy()
|
||||
repl.on 'line', run
|
||||
|
||||
Reference in New Issue
Block a user