Last active
August 29, 2015 14:15
-
-
Save francesko/46fef424c30b085fe81a to your computer and use it in GitHub Desktop.
compile js files to coffee looking recursively into subdirectories and outputting to given folder
This file contains hidden or 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
#!/bin/bash | |
# requires https://www.npmjs.com/package/js2coffee | |
INPUT_FOLDER=$1 | |
OUTPUT_FOLDER=$2 | |
mkdir -p ${OUTPUT_FOLDER} | |
JS_FILE_LIST="`find ${INPUT_FOLDER} -type f -regex ".*\.\(js\)"`" | |
for js_file in ${JS_FILE_LIST} | |
do | |
echo "compiling ${js_file} to coffee" | |
COFFEE_FILE="`sed 's,^[^/]*/,,' <<< "${js_file%.js}.coffee"`" | |
COFFEE_FILE="${OUTPUT_FOLDER}/${COFFEE_FILE}" | |
COFFEE_DIR=$(dirname "${COFFEE_FILE}") | |
`mkdir -p ${COFFEE_DIR}` | |
`js2coffee ${js_file} > ${COFFEE_FILE}` | |
done | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment