Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coffeescript watch src directory to compile

I am doing this -

$ coffee -c assets/js

To compile all .coffee files into .js files in that directory. But i don't understand how I can watch the directory ?

I try this but get error -

$ coffee -wc assets/js

/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:287
      if (e.code !== 'ENOENT') throw e;
                                     ^
Error: watch EMFILE
    at errnoException (fs.js:648:11)
    at FSWatcher.start (fs.js:676:11)
    at Object.watch (fs.js:704:11)
    at /usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:256:27
    at Object.oncomplete (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:85:25)

Any help will be greatly appreciated!

like image 338
user1437328 Avatar asked Jun 19 '12 15:06

user1437328


2 Answers

In one of my cake files I do this:

"coffee -o javascript/ -cw coffeescript/"

All of my .coffee files are in the coffeescript folder, and this compiles them into the same hierarchy in the javascript folder, as well as watching them.

It's from the docs. Hope it helps.

like image 118
phenomnomnominal Avatar answered Sep 28 '22 13:09

phenomnomnominal


Tested with CoffeeScript 1.7.1

in command line:

coffee -wc DIR
  • w = watch
  • c = compile
like image 44
Ernestas Poskus Avatar answered Sep 28 '22 11:09

Ernestas Poskus