Last active
November 6, 2018 20:37
-
-
Save deconstructionalism/4e99fb245c5b61b1aae1f3d3a4281410 to your computer and use it in GitHub Desktop.
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/sh | |
| print_header () { | |
| echo $1 | |
| echo "------------------------------------" | |
| } | |
| run_print_error () { | |
| print_header "$2" | |
| echo $1 | |
| # error_msg=$($1 2>&1 >/dev/null) | |
| if error_msg=$($1 2>&1 >/dev/null); then | |
| echo "SUCCESS!\n\n" | |
| else | |
| echo "\nERROR!\n$error_msg\n" | |
| exit 1 | |
| fi | |
| } | |
| # install gem packages | |
| run_print_error "gem install rubocop" "Installing Global Rubocop" | |
| if grep -q Microsoft /proc/version 1>/dev/null 2>/dev/null; then | |
| # -------------------- # | |
| # W I N D O W S 1 0 # | |
| # -------------------- # | |
| # install Atom packages | |
| run_print_error "powershell.exe -command Start-Process powershell -Verb runAs -ArgumentList 'apm install linter linter-rubocop'" "Installing Atom Extensions linter, linter-rubocop" | |
| $cmd | |
| print_header "Fixing Atom line-endings" | |
| # set default line endings to LF | |
| echo "atom.config.set(\"line-ending-selector.defaultLineEnding\", \"LF\")" >> ~/winhome/.atom/init.coffee | |
| echo "SUCCESS!\n\n" | |
| # ------------------------------------------ # | |
| # BATCH SCRIPTS TO BIND WSL BINARIES TO ATOM # | |
| # ------------------------------------------ # | |
| # Atom will use binaries installed in WSL to run linting and other | |
| # functionality. In order for Atom, a Windows 10 program to use WSL | |
| # binaries, we need simple batch scripts to allow calling WSL binaries | |
| # from Atom. | |
| print_header "Generating rubocop batch file" | |
| # WSL rubocop batch file | |
| cat <<EOF > ~/winhome/.atom/rubocop.bat | |
| @echo off | |
| bash.exe -c "$(rbenv which rubocop) %*" | |
| EOF | |
| echo "SUCCESS!\n\n" | |
| print_header "Setting Atom rubocop path" | |
| # set rubocop path to batch file | |
| echo "atom.config.set(\"linter-rubocop.command\", \"%USERPROFILE%/.atom/rubocop.bat\")" >> ~/winhome/.atom/init.coffee | |
| echo "SUCCESS!\n\n" | |
| else | |
| # ---------------------------- # | |
| # M A C O S / L I N U X # | |
| # ---------------------------- # | |
| # install Atom packages | |
| run_print_error "apm install linter linter-rubocop" "Installing Atom Extensions linter, linter-rubocop" | |
| print_header "Setting Atom rubocop path" | |
| # add command to set correct rubocop path to Atom init screen | |
| echo "atom.config.set(\"linter-rubocop.command\", \"`rbenv which rubocop`\")" >> ~/.atom/init.coffee | |
| echo "SUCCESS!\n\n" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment