Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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