Created
November 9, 2013 01:25
-
-
Save dre1080/7380287 to your computer and use it in GitHub Desktop.
Js2Coffee a directory recursively. Excludes node_modules, app/assets and public directories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for FILE in `find . -name "*.js" -type f -o -path './node_modules' -prune -o -path './app/assets' -prune -o -path './public' -prune` | |
do | |
if [ -e $FILE ] ; then | |
COFFEE=${FILE//.js/.coffee} | |
echo "converting ${FILE} to ${COFFEE}" | |
js2coffee "$FILE" > "$COFFEE" | |
else | |
echo "File: {$1} does not exist!" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! Extremely helpful.
I would suggest changing
'./node_modules'
to simply'node_modules'
(same withcomponents
) so that subdirs aren't converted either.I also found this addition at the top of the file helpful:
Then replacing
.
with$DIR
in the find command. This way, you can pass in a directory to the command.