-
-
Save islandjoe/a374b78096822964381792485354e20d to your computer and use it in GitHub Desktop.
Run ES6 in Coderunner via Babel
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 | |
# | |
# This script will create transpile ES6 (with JSX) support in babel | |
# to ES5 that evaluatable in regular node.js | |
# Script will create a filename.out file, evaluates it, then remove the file. | |
# | |
# First off, you'll need Node.js. | |
# | |
# Steps: | |
# 1) Install babel globally npm install -g babel-cli | |
# 2) Create new language in Coderunner preferences Eg. Babel | |
# 3) Check "Language uses compile script" | |
# 4) Click "Edit Script" button, which will create/open compile script | |
# 5) Copy and paste this file, save! | |
# 6) Reopen preferences of the new created language | |
# 7) Inside "Run Command" input, paste this line | |
# /usr/local/bin/node $compiler&&rm $compiler | |
# | |
out=`echo "$CR_FILENAME" | sed 's/\(.*\)\..*/\1/'` | |
if [ -d "$out" ]; then | |
out="$out.out" | |
fi | |
~/.npm-packages/bin/babel --stage 0 -o "$out" "$CR_FILENAME" "${@:1}" | |
status=$? | |
if [ $status -eq 0 ] | |
then | |
echo "$out" | |
fi | |
exit $status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A "fix" for this error:
Library/Application Support/CodeRunner/Languages/Babel.crLanguage/Scripts/compile.sh: line 25: babel: command not found