Proper way to compile coffee for packages?


#1

I am firing up child processes and the node spawn command requires a javascript file to run. I’m writing the code for the child process in coffeescript. What is the best way to ship an apm module that needs one or two JS files compiled from CS?

I know core modules ship with only the JS from the CS compiler. Does anyone know what tool chain they use?

I’m using the built-in watcher in coffee such as coffee -cwo ../js child.coffee but is there a more “Atom” way to do this?


#2

The Atom core uses a grunt task to compile coffee files:

https://github.com/atom/atom/blob/master/build/Gruntfile.coffee#L68-L77

I do so myself for npm modules:


#3

Ok, I’ll give in and finally learn grunt.


#4

I finally tried grunt and it is great. Read the docs, stole some of your code, and had it running in about 30 mins.


#5

One more question.

  • Is there a way to automatically start grunt watching when I open a project in atom?

  • (no, 2 questions). If it can’t be opened automatically then I need to manually open a command window and type grunt. Right now if I’m working on three packages at once, the main and two plugins, and I have to have three command windows open all the time. Can I have one grunt watch more than one package? Maybe I already know the answer which is duh.


#6
alias atom='atom && grunt watch'

:stuck_out_tongue:

More seriously, I don’t think there’s any binding with projects build systems yet. This will probably come in at some point, but dealing with make, rake, cake, grunt, gulp, etc. will require a serious groundwork in the core.

About your second question, I think the first thing I install in my terminal when I setup a new computer is a terminal multiplexer, so I’m not really affected by having three panes with my watchers in a single terminal window (if having many terminal windows is an issue), and by experience I know I will frequently restart the watcher in a project when working on it.

Looking at the problem, I found that module: grunt-subgrunt that you can supposedly use to setup a master project and running tasks of its sub projects from the master gruntfile, but as watch tasks never terminate themselves I wonder if it’ll works. I have not tried it yet but if it works sequencially then it’s a dead end. But if it works, you can put your package’s plugins directories in the main package (and listed in its .gitignore) and you should be able to grunt watch your package and all its plugins at once.


#7

Unfortunately I’d end up with a 100 command windows. (grin)

Why? I’ve never had that happen. My old CS watchers would run for a week.

It’s just a matter of screen real estate. I need to be able to see at least the bottom few lines of at all times. I often have my sound off. It would be cool if it could just show a notification on the screen on a compile error.