3

I am currently using this node.js command to watch coffeescript files for changes and compile them to a folder:

coffee -cwo ./js ./src

I wonder if there is a way to watch a folder/files for changes and if there is a change, run a compiled js file.

In this way I don't have to manually run "coffee file.coffee" each time I made a change in coffeescript files.

1 Answer 1

3

You can either save the compiled JS or run it with a single coffee command, but not both. The command to run the .coffee files in src every time they change is simply

coffee -w src

For more complex compilation needs, you should write a Cakefile. Check out the one in sstephenson's node-coffee-project, for instance. That way, you can customize the whole compilation pipeline for your project's needs, e.g. compile -> run tests -> run the project if tests passed.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually that was really helpful. I run both commands and now when I change the CS files the ./js files will be changed, and when they are changed the other command is running the changed file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.