Skip to content

Commit

Permalink
Merge branch 'Sandstorm-Station:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MosleyTheMalO authored Oct 24, 2024
2 parents 518fea2 + 0aad8b5 commit 14e095d
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions tools/bootstrap/node
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ if [ "$TG_BOOTSTRAP_CACHE" ]; then
fi
OldPWD="$PWD"
cd "$Bootstrap/../.."
. ./dependencies.sh # sets NODE_VERSION_PRECISE
. ./dependencies.sh # sets NODE_VERSION_LTS
cd "$OldPWD"
NodeVersion="$NODE_VERSION_PRECISE"
NodeVersion="$NODE_VERSION_LTS"
NodeFullVersion="node-v$NodeVersion-win-x64"
NodeDir="$Cache/$NodeFullVersion"
NodeExe="$NodeDir/node.exe"
Log="$Cache/last-command.log"
is_vendored="1"

# If a bootstrapped Node is not present, search on $PATH.
if [ "$(uname)" = "Linux" ] || [ ! -f "$NodeExe" ]; then
Expand All @@ -39,6 +39,7 @@ if [ "$(uname)" = "Linux" ] || [ ! -f "$NodeExe" ]; then
fi
elif command -v node >/dev/null 2>&1; then
NodeExe="node"
is_vendored="0"
else
echo
if command -v apt-get >/dev/null 2>&1; then
Expand All @@ -62,23 +63,11 @@ if [ "$(uname)" = "Linux" ] || [ ! -f "$NodeExe" ]; then
fi
fi

# Cheap shell function if tee.exe is not available
if ! command -v tee >/dev/null 2>&1; then
tee() {
# Fudge: assume $1 is always "-a"
while read -r line; do
echo "$line" >> "$2"
echo "$line"
done
}
fi

# Invoke Node with all command-line arguments
mkdir -p "$Cache"
printf '%s\n' "$NodeExe" "$@" > "$Log"
printf -- '---\n' >> "$Log"
exec 4>&1
PATH="$(readlink -f "$NodeDir"):$PATH" # Set PATH so that recursive calls find it
exitstatus=$({ { set +e; "$NodeExe" "$@" 2>&1 3>&-; printf %s $? >&3; } 4>&- | tee -a "$Log" 1>&4; } 3>&1)
exec 4>&-
exit "$exitstatus"
if [ "$is_vendored" = "1" ]; then
PATH="$(readlink -f "$NodeDir"):$PATH"
echo "Using vendored Node $("$NodeExe" --version)"
else
echo "Using system-wide Node $("$NodeExe" --version)"
fi
exec "$NodeExe" "$@"

0 comments on commit 14e095d

Please sign in to comment.