Created
March 18, 2011 01:12
-
-
Save mathieuravaux/875462 to your computer and use it in GitHub Desktop.
Fellow Noders - Rubyists, treat your muscle memory! `edit` will correctly use `bundle open` or `npm edit` whether `Gemfile.lock` or `package.json` are in the Git root.
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
function edit { | |
if [[ "$1" == "" ]]; then echo "usage: edit NAME (NAME is a bundled gem or npm package)"; return; fi | |
RES=$(git rev-parse --quiet --is-inside-work-tree 2>&1) | |
if [[ "$?" == "0" ]]; then | |
GIT_DIR=$(git rev-parse --show-toplevel) | |
if [[ -f "$GIT_DIR/package.json" ]]; then | |
npm edit $1 | |
fi | |
if [[ -f "$GIT_DIR/Gemfile" ]]; then | |
bundle open $1 | |
fi | |
else | |
echo "Error: not in a git working copy." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment