Created
November 23, 2015 03:41
-
-
Save diniremix/89ef6960bf43d4ffcac8 to your computer and use it in GitHub Desktop.
script to compile js to coffeescript, using SublimeText 2
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
#!/bin/bash | |
if [ $# -le 0 ];then | |
echo -e $0: Especifique un nombre de archivo javascript; | |
exit 1; | |
fi | |
JS=$1; | |
function convert() { | |
if [ -e $JS ]; then | |
FILENAME=$(basename "$JS") | |
DIRNAME=$(dirname "$JS") | |
echo -e Compilando archivo: "$FILENAME" | |
REPLACE=".coffee" | |
COFFEE=$(echo -n $FILENAME | sed -e "s/.js/${REPLACE}/g") | |
js2coffee -V $JS > "$DIRNAME/$COFFEE" | |
if [ -e $JS ]; then | |
echo -e Archivo de salida: "$DIRNAME/$COFFEE" | |
else | |
echo -e Ocurrio un error al compilar el archivo | |
fi | |
else | |
echo -e $1: No existe el archivo javascript; | |
fi | |
} | |
convert; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
script to compile js to coffeescript, using SublimeText 2 .
install a plugin js2coffee
apply execute permissions:
sudo chmod +x js2coffee.sh**
copy this file to /usr/local/bin or ~/bin
enjoy!