Skip to content

Instantly share code, notes, and snippets.

@doxavore
Created September 14, 2012 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doxavore/3722096 to your computer and use it in GitHub Desktop.
Save doxavore/3722096 to your computer and use it in GitHub Desktop.
Convert all CoffeeScript files to JavaScript

Is this really necessary? It seems like a bit of work...

In Vim, make all comments stick:

:arg **/*.js.coffee
:argdo %s/^\(\s*\)#/\1#!/ge

Compile from CoffeeScript to JavaScript (npm install -g coffee-script):

cd app/assets/javascripts
coffee --compile ./

This creates *.js.js files, so strip off one of the .js with:

find . -name '*.js.js'  | sed 's/\(.*\).js.js/mv & \1.js/' | sh

Finally, remove all the .js.coffee files:

find . -name '*.js.coffee'  | sed 's/\(.*\).js.coffee/rm &/' | sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment