Skip to content

Instantly share code, notes, and snippets.

@diniremix
Created November 23, 2015 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diniremix/89ef6960bf43d4ffcac8 to your computer and use it in GitHub Desktop.
Save diniremix/89ef6960bf43d4ffcac8 to your computer and use it in GitHub Desktop.
script to compile js to coffeescript, using SublimeText 2
#!/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;
@diniremix
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment