From 03ff99ee616498462c02f3d0e807f17cfe728263 Mon Sep 17 00:00:00 2001 From: Sam Saccone Date: Tue, 10 Dec 2013 21:44:05 -0500 Subject: [PATCH] abstract watcher events to use methods adds to the readability of the watcher file --- lib/commands/watch.coffee | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/commands/watch.coffee b/lib/commands/watch.coffee index 3202ec78..1d392a1e 100644 --- a/lib/commands/watch.coffee +++ b/lib/commands/watch.coffee @@ -9,8 +9,20 @@ exports.execute = (args)-> project = new Roots(dir) process.stdout.write('compiling... '.grey) - - project.watch() - .on('start', -> process.stdout.write('compiling... '.grey)) - .on('error', console.error.bind(console)) - .on('done', -> process.stdout.write('done!\n'.green)) + + w = project.watch() + + w.on 'start', onStart + w.on 'error', onError + w.on 'done', onDone + + w + +onError = (err) -> + process.stdout.write JSON.stringify(err).red + +onStart = -> + process.stdout.write 'compiling... '.grey + +onDone = -> + process.stdout.write 'done!\n'.green