npm-flexjs: shell scripts detect sdk location by detecting if they were run as 
symlinks, if required (references #8)


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/96f4e398
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/96f4e398
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/96f4e398

Branch: refs/heads/feature/flash-downloader
Commit: 96f4e398a8895500f33bb197858222f47c951f7e
Parents: 1cd590f
Author: Josh Tynjala <joshtynj...@apache.org>
Authored: Wed Aug 17 15:39:31 2016 -0700
Committer: Josh Tynjala <joshtynj...@apache.org>
Committed: Wed Aug 17 15:40:27 2016 -0700

----------------------------------------------------------------------
 npm-flexjs/js/bin/asjscnpm     | 14 ++++++++++----
 npm-flexjs/js/bin/asjscompcnpm | 14 ++++++++++----
 npm-flexjs/js/bin/mxmlcnpm     | 14 ++++++++++----
 3 files changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/96f4e398/npm-flexjs/js/bin/asjscnpm
----------------------------------------------------------------------
diff --git a/npm-flexjs/js/bin/asjscnpm b/npm-flexjs/js/bin/asjscnpm
index cc7570f..1b4ffc2 100755
--- a/npm-flexjs/js/bin/asjscnpm
+++ b/npm-flexjs/js/bin/asjscnpm
@@ -25,10 +25,16 @@
 # In Windows Command Prompt, use mxmlc.bat instead.
 #
 
-function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs 
-l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" 
]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename 
\"$1\"`"; fi; fi; popd > /dev/null; }
-SCRIPT_REAL_FILE=`readlink "$0" || echo "$0"`;
-SCRIPT_ABS_PATH=`abspath "$SCRIPT_REAL_FILE"`
-SCRIPT_HOME=`dirname "$SCRIPT_ABS_PATH"`
+SCRIPT_HOME="$0"
+# try to find the real script if $0 is a symlink
+pushd . > /dev/null
+if [ -h "$SCRIPT_HOME" ]; then
+       cd "`dirname "$SCRIPT_HOME"`"
+       SCRIPT_HOME="`readlink "\`basename $SCRIPT_HOME\`"`"
+fi
+cd "`dirname "${SCRIPT_HOME}"`"
+SCRIPT_HOME="`pwd`"
+popd > /dev/null
 FALCON_HOME=${SCRIPT_HOME}/../..
 FLEX_HOME=${SCRIPT_HOME}/../..
 

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/96f4e398/npm-flexjs/js/bin/asjscompcnpm
----------------------------------------------------------------------
diff --git a/npm-flexjs/js/bin/asjscompcnpm b/npm-flexjs/js/bin/asjscompcnpm
index 0435aac..4e4d322 100755
--- a/npm-flexjs/js/bin/asjscompcnpm
+++ b/npm-flexjs/js/bin/asjscompcnpm
@@ -25,10 +25,16 @@
 # In Windows Command Prompt, use mxmlc.bat instead.
 #
 
-function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs 
-l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" 
]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename 
\"$1\"`"; fi; fi; popd > /dev/null; }
-SCRIPT_REAL_FILE=`readlink "$0" || echo "$0"`;
-SCRIPT_ABS_PATH=`abspath "$SCRIPT_REAL_FILE"`
-SCRIPT_HOME=`dirname "$SCRIPT_ABS_PATH"`
+SCRIPT_HOME="$0"
+# try to find the real script if $0 is a symlink
+pushd . > /dev/null
+if [ -h "$SCRIPT_HOME" ]; then
+       cd "`dirname "$SCRIPT_HOME"`"
+       SCRIPT_HOME="`readlink "\`basename $SCRIPT_HOME\`"`"
+fi
+cd "`dirname "${SCRIPT_HOME}"`"
+SCRIPT_HOME="`pwd`"
+popd > /dev/null
 FALCON_HOME=${SCRIPT_HOME}/../..
 FLEX_HOME=${SCRIPT_HOME}/../..
 

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/96f4e398/npm-flexjs/js/bin/mxmlcnpm
----------------------------------------------------------------------
diff --git a/npm-flexjs/js/bin/mxmlcnpm b/npm-flexjs/js/bin/mxmlcnpm
index 1546763..f344768 100755
--- a/npm-flexjs/js/bin/mxmlcnpm
+++ b/npm-flexjs/js/bin/mxmlcnpm
@@ -25,10 +25,16 @@
 # In Windows Command Prompt, use mxmlc.bat instead.
 #
 
-function abspath() { pushd . > /dev/null; if [ -d "$1" ]; then cd "$1"; dirs 
-l +0; else cd "`dirname \"$1\"`"; cur_dir=`dirs -l +0`; if [ "$cur_dir" == "/" 
]; then echo "$cur_dir`basename \"$1\"`"; else echo "$cur_dir/`basename 
\"$1\"`"; fi; fi; popd > /dev/null; }
-SCRIPT_REAL_FILE=`readlink "$0" || echo "$0"`;
-SCRIPT_ABS_PATH=`abspath "$SCRIPT_REAL_FILE"`
-SCRIPT_HOME=`dirname "$SCRIPT_ABS_PATH"`
+SCRIPT_HOME="$0"
+# try to find the real script if $0 is a symlink
+pushd . > /dev/null
+if [ -h "$SCRIPT_HOME" ]; then
+    cd "`dirname "$SCRIPT_HOME"`"
+    SCRIPT_HOME="`readlink "\`basename $SCRIPT_HOME\`"`"
+fi
+cd "`dirname "${SCRIPT_HOME}"`"
+SCRIPT_HOME="`pwd`"
+popd > /dev/null
 if [ "x${FALCON_HOME}" = "x" ]
 then
     FALCON_HOME=${SCRIPT_HOME}/../..

Reply via email to