Skip to content

Instantly share code, notes, and snippets.

@jhoff
Forked from dclowd9901/jshint-install.sh
Created December 10, 2012 18:22
Show Gist options
  • Save jhoff/4252297 to your computer and use it in GitHub Desktop.
Save jhoff/4252297 to your computer and use it in GitHub Desktop.
jshint-install
#!/bin/sh
USERNAME=$(id -un)
if [ $(uname) = 'Darwin' ]; then
SUBL_PATH=/Users/$USERNAME/Library/Application\ Support/Sublime\ Text\ 2/Packages
else
SUBL_PATH=/home/$USERNAME/.config/sublime-text-2/Packages
fi
update_jshintrc()
{
curl http://viewvc.corp.linkedin.com/viewvc/netrepo/network/trunk/content/static/.jshintrc?view=co# > ~/.jshintrc
}
if [ $1 = 'update' ]; then
echo "Updating your local .jshintrc..."
update_jshintrc
exit 0
else
echo "Downloading most current version of .jshintrc from trunk..."
update_jshintrc
fi
# Escaped $file and $packages for Sublime Text 2 (python-specific) build variables
NEW_CONFIG_LINE="\"cmd\": [\"jshint\", \"\$file\", \"--reporter\", \"\$packages/JSHint/reporter.js\", \"--config\", \"~/.jshintrc\"],"
echo "Installing JSHint globally..."
sudo npm install -g jshint
if [ -d $SUBL_PATH ]; then
cd $SUBL_PATH
sudo mkdir JSHint
echo "Installing JSHint Sublime Text package..."
sudo git clone git://github.com/uipoet/sublime-jshint.git JSHint
echo "Editing JSHint.sublime-build..."
cd $SUBL_PATH/JSHint/
sudo sed -E "s/\"cmd\".+\"jshint\".+/$(echo $NEW_CONFIG_LINE | sed -e 's/[\/&]/\\&/g')/" <JSHint.sublime-build | sudo tee newJSHint.sublime-build && sudo mv newJSHint.sublime-build JSHint.sublime-build
cd $SUBL_PATH
sudo mkdir SublimeOnSaveBuild
echo "Installing SublimeText 2 BuildOnSave plugin..."
sudo git clone git://github.com/alexnj/SublimeOnSaveBuild.git SublimeOnSaveBuild
echo "Successful! Simply start Sublime Text 2 and on saving any Javascript file, your file will be checked for JSHint compliance."
fi
if [ -d ~/Library/Application\ Support/TextMate ]; then
echo "Installing TextMate JSHint..."
mkdir -p ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles
cd ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles
git clone git://github.com/rondevera/jslintmate.git "JavaScript JSLintMate.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment