1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Moving from '.addListener' to '.on' for Node v0.1.101

This commit is contained in:
Jeremy Ashkenas 2010-07-18 07:54:44 -04:00
parent 5a34f53689
commit d017a8f9f7
5 changed files with 18 additions and 18 deletions

View file

@ -10,9 +10,9 @@ reset: '\033[0m'
# Run a CoffeeScript through our node/coffee interpreter. # Run a CoffeeScript through our node/coffee interpreter.
run: (args) -> run: (args) ->
proc: spawn 'bin/coffee', args proc: spawn 'bin/coffee', args
proc.stderr.addListener 'data', (buffer) -> puts buffer.toString() proc.stderr.on 'data', (buffer) -> puts buffer.toString()
proc.addListener 'exit', (status) -> process.exit(1) if status != 0 proc.on 'exit', (status) -> process.exit(1) if status != 0
# Log a message with a color. # Log a message with a color.
log: (message, color, explanation) -> log: (message, color, explanation) ->
@ -100,7 +100,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
ok: (args...) -> passedTests += 1; originalOk(args...) ok: (args...) -> passedTests += 1; originalOk(args...)
CoffeeScript: CoffeeScript CoffeeScript: CoffeeScript
} }
process.addListener 'exit', -> process.on 'exit', ->
time: ((new Date - startTime) / 1000).toFixed(2) time: ((new Date - startTime) / 1000).toFixed(2)
message: "passed $passedTests tests in $time seconds$reset" message: "passed $passedTests tests in $time seconds$reset"
if failedTests if failedTests

View file

@ -120,12 +120,12 @@
var code, stdin; var code, stdin;
code = ''; code = '';
stdin = process.openStdin(); stdin = process.openStdin();
stdin.addListener('data', function(buffer) { stdin.on('data', function(buffer) {
if (buffer) { if (buffer) {
return code += buffer.toString(); return code += buffer.toString();
} }
}); });
return stdin.addListener('end', function() { return stdin.on('end', function() {
return compileScript('stdio', code); return compileScript('stdio', code);
}); });
}; };
@ -166,8 +166,8 @@
return print(buffer.toString()); return print(buffer.toString());
}; };
jsl = spawn('jsl', ['-nologo', '-stdin']); jsl = spawn('jsl', ['-nologo', '-stdin']);
jsl.stdout.addListener('data', printIt); jsl.stdout.on('data', printIt);
jsl.stderr.addListener('data', printIt); jsl.stderr.on('data', printIt);
jsl.stdin.write(js); jsl.stdin.write(js);
return jsl.stdin.end(); return jsl.stdin.end();
}; };

View file

@ -27,12 +27,12 @@
}; };
repl = readline.createInterface(stdio); repl = readline.createInterface(stdio);
repl.setPrompt('coffee> '); repl.setPrompt('coffee> ');
stdio.addListener('data', function(buffer) { stdio.on('data', function(buffer) {
return repl.write(buffer); return repl.write(buffer);
}); });
repl.addListener('close', function() { repl.on('close', function() {
return stdio.destroy(); return stdio.destroy();
}); });
repl.addListener('line', run); repl.on('line', run);
repl.prompt(); repl.prompt();
})(); })();

View file

@ -106,9 +106,9 @@ compileScript: (source, code, base) ->
compileStdio: -> compileStdio: ->
code: '' code: ''
stdin: process.openStdin() stdin: process.openStdin()
stdin.addListener 'data', (buffer) -> stdin.on 'data', (buffer) ->
code: + buffer.toString() if buffer code: + buffer.toString() if buffer
stdin.addListener 'end', -> stdin.on 'end', ->
compileScript 'stdio', code compileScript 'stdio', code
# Watch a source CoffeeScript file using `fs.watchFile`, recompiling it every # Watch a source CoffeeScript file using `fs.watchFile`, recompiling it every
@ -139,8 +139,8 @@ writeJs: (source, js, base) ->
lint: (js) -> lint: (js) ->
printIt: (buffer) -> print buffer.toString() printIt: (buffer) -> print buffer.toString()
jsl: spawn 'jsl', ['-nologo', '-stdin'] jsl: spawn 'jsl', ['-nologo', '-stdin']
jsl.stdout.addListener 'data', printIt jsl.stdout.on 'data', printIt
jsl.stderr.addListener 'data', printIt jsl.stderr.on 'data', printIt
jsl.stdin.write js jsl.stdin.write js
jsl.stdin.end() jsl.stdin.end()

View file

@ -31,7 +31,7 @@ run: (buffer) ->
# Create the REPL by listening to **stdin**. # Create the REPL by listening to **stdin**.
repl: readline.createInterface stdio repl: readline.createInterface stdio
repl.setPrompt 'coffee> ' repl.setPrompt 'coffee> '
stdio.addListener 'data', (buffer) -> repl.write buffer stdio.on 'data', (buffer) -> repl.write buffer
repl.addListener 'close', -> stdio.destroy() repl.on 'close', -> stdio.destroy()
repl.addListener 'line', run repl.on 'line', run
repl.prompt() repl.prompt()