Skip to content

Instantly share code, notes, and snippets.

@yuya
Last active August 29, 2015 14:01
Show Gist options
  • Save yuya/90a08b25df0dfe1c473e to your computer and use it in GitHub Desktop.
Save yuya/90a08b25df0dfe1c473e to your computer and use it in GitHub Desktop.
Coffee Script to JSON
#!/bin/sh
if ! type coffee > /dev/null 2>&1; then echo "Please install the coffee-script."; exit; fi
if [[ ! "${1}" =~ \.coffee$ ]]; then echo "File extension error"; exit; fi
echo \{
cat $1 | \
coffee --print --bare --compile --stdio | \
sed -e '1,2d; $d' | \
sed "s/\([^ '\"].*[^ '\"]\): /\"\1\": /"
echo \}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment