Skip to content

Instantly share code, notes, and snippets.

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 **/*
: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 files:

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