Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output when watching CoffeeScript files from a cakefile task

Tags:

coffeescript

I would like to make a Cakefile task to watch some CoffeeScript files just like if I had run coffee -c -w js/*.coffee.

Its watching and recompiling them successfully, but it doesn't log the usual output to the terminal when there's a compile error like it would if I just ran the script from the terminal. Any idea how to make this happen?

exec = require('child_process').exec

task 'watch','watch all files and compile them as needed', (options) ->
    exec 'coffee -c -w js/*.coffee', (err,stdout, stderr) ->
        console.log stdout

Also, if there's a better way to invoke a coffeescript command from a cakefile than running 'exec' please post that too.

like image 681
Derek Dahmer Avatar asked Feb 03 '23 22:02

Derek Dahmer


1 Answers

spawn instead of exec?

{spawn} = require 'child_process'

task 'watch', -> spawn 'coffee', ['-cw', 'js'], customFds: [0..2]
like image 126
matyr Avatar answered Feb 05 '23 12:02

matyr