From d017a8f9f7e3d83343b7797f70f501eb253a22f0 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sun, 18 Jul 2010 07:54:44 -0400 Subject: [PATCH] Moving from '.addListener' to '.on' for Node v0.1.101 --- Cakefile | 8 ++++---- lib/command.js | 8 ++++---- lib/repl.js | 6 +++--- src/command.coffee | 8 ++++---- src/repl.coffee | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Cakefile b/Cakefile index 09c8a658..098f6c97 100644 --- a/Cakefile +++ b/Cakefile @@ -10,9 +10,9 @@ reset: '\033[0m' # Run a CoffeeScript through our node/coffee interpreter. run: (args) -> - proc: spawn 'bin/coffee', args - proc.stderr.addListener 'data', (buffer) -> puts buffer.toString() - proc.addListener 'exit', (status) -> process.exit(1) if status != 0 + proc: spawn 'bin/coffee', args + proc.stderr.on 'data', (buffer) -> puts buffer.toString() + proc.on 'exit', (status) -> process.exit(1) if status != 0 # Log a message with a color. log: (message, color, explanation) -> @@ -100,7 +100,7 @@ task 'test', 'run the CoffeeScript language test suite', -> ok: (args...) -> passedTests += 1; originalOk(args...) CoffeeScript: CoffeeScript } - process.addListener 'exit', -> + process.on 'exit', -> time: ((new Date - startTime) / 1000).toFixed(2) message: "passed $passedTests tests in $time seconds$reset" if failedTests diff --git a/lib/command.js b/lib/command.js index 7c6ac612..729cffda 100644 --- a/lib/command.js +++ b/lib/command.js @@ -120,12 +120,12 @@ var code, stdin; code = ''; stdin = process.openStdin(); - stdin.addListener('data', function(buffer) { + stdin.on('data', function(buffer) { if (buffer) { return code += buffer.toString(); } }); - return stdin.addListener('end', function() { + return stdin.on('end', function() { return compileScript('stdio', code); }); }; @@ -166,8 +166,8 @@ return print(buffer.toString()); }; jsl = spawn('jsl', ['-nologo', '-stdin']); - jsl.stdout.addListener('data', printIt); - jsl.stderr.addListener('data', printIt); + jsl.stdout.on('data', printIt); + jsl.stderr.on('data', printIt); jsl.stdin.write(js); return jsl.stdin.end(); }; diff --git a/lib/repl.js b/lib/repl.js index 01383332..b33e3951 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -27,12 +27,12 @@ }; repl = readline.createInterface(stdio); repl.setPrompt('coffee> '); - stdio.addListener('data', function(buffer) { + stdio.on('data', function(buffer) { return repl.write(buffer); }); - repl.addListener('close', function() { + repl.on('close', function() { return stdio.destroy(); }); - repl.addListener('line', run); + repl.on('line', run); repl.prompt(); })(); diff --git a/src/command.coffee b/src/command.coffee index f55e5c0b..ca4b2b66 100644 --- a/src/command.coffee +++ b/src/command.coffee @@ -106,9 +106,9 @@ compileScript: (source, code, base) -> compileStdio: -> code: '' stdin: process.openStdin() - stdin.addListener 'data', (buffer) -> + stdin.on 'data', (buffer) -> code: + buffer.toString() if buffer - stdin.addListener 'end', -> + stdin.on 'end', -> compileScript 'stdio', code # Watch a source CoffeeScript file using `fs.watchFile`, recompiling it every @@ -139,8 +139,8 @@ writeJs: (source, js, base) -> lint: (js) -> printIt: (buffer) -> print buffer.toString() jsl: spawn 'jsl', ['-nologo', '-stdin'] - jsl.stdout.addListener 'data', printIt - jsl.stderr.addListener 'data', printIt + jsl.stdout.on 'data', printIt + jsl.stderr.on 'data', printIt jsl.stdin.write js jsl.stdin.end() diff --git a/src/repl.coffee b/src/repl.coffee index 1b2bdb64..bdc69fc3 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -31,7 +31,7 @@ run: (buffer) -> # Create the REPL by listening to **stdin**. repl: readline.createInterface stdio repl.setPrompt 'coffee> ' -stdio.addListener 'data', (buffer) -> repl.write buffer -repl.addListener 'close', -> stdio.destroy() -repl.addListener 'line', run +stdio.on 'data', (buffer) -> repl.write buffer +repl.on 'close', -> stdio.destroy() +repl.on 'line', run repl.prompt()