Skip to content

Instantly share code, notes, and snippets.

@takumakei
Created April 8, 2014 16:53
Show Gist options
  • Save takumakei/10155224 to your computer and use it in GitHub Desktop.
Save takumakei/10155224 to your computer and use it in GitHub Desktop.
Homebrew formula for the Deploygate cli
require 'formula'
class Dgate < Formula
homepage 'https://deploygate.com/docs/cli'
url 'https://deploygate.com/client/dgate.tar.gz'
sha1 '23e3723bf01f6fbca0a097fc895ca9812a8c9de3'
version '0.0.1'
patch :DATA
def install
rm Dir['bin/*']
libexec.install Dir['*']
bin.install_symlink Dir["#{libexec}/dgate"]
end
end
__END__
diff --git a/dgate b/dgate
index aee2843..ec36bc8 100755
--- a/dgate
+++ b/dgate
@@ -1,9 +1,16 @@
#!/bin/sh
ORIG_DIR=$(pwd)
-cd $(dirname "$0")
-if [ -L "$(basename $0)" ] ; then
- cd $(dirname $(readlink $(basename "$0") ) )
-fi
-SCRIPT_DIR=$(pwd -P)
+PRG="$0"
+# resolve relative/absolute symlinks
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+done
+SCRIPT_DIR=`dirname $PRG`
cd "$ORIG_DIR"
ruby -I $SCRIPT_DIR/lib $SCRIPT_DIR/dgate.rb "$@"
@takumakei
Copy link
Author

$ brew install https://gist.githubusercontent.com/takumakei/10155224/raw/dgate.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment