-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing nodejs executable for mac and linux
- Loading branch information
1 parent
e9424d3
commit 11baeec
Showing
7 changed files
with
61 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,71 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Define Node.js version and base URL | ||
NODE_VERSION="v18.20.5" | ||
NODE_BASE_URL="https://nodejs.org/download/release/${NODE_VERSION}" | ||
NODE_INSTALL_DIR="./node" | ||
|
||
cd "$(dirname "$0")/app" | ||
|
||
which node 2>/dev/null | ||
isNode=$? | ||
echo NodeJS status = $isNode | ||
# Function to determine the appropriate Node.js binary | ||
get_node_binary_url() { | ||
OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]') | ||
MACHINE_TYPE=$(uname -m) | ||
|
||
case "${OS_TYPE}" in | ||
linux) | ||
case "${MACHINE_TYPE}" in | ||
x86_64) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-linux-x64.tar.gz" ;; | ||
*64) | ||
# If the machine type ends with '64' and is not x86_64, assume it's ARM64 | ||
echo "${NODE_BASE_URL}/node-${NODE_VERSION}-linux-arm64.tar.gz" ;; | ||
armv7l) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-linux-armv7l.tar.gz" ;; | ||
ppc64le) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-linux-ppc64le.tar.gz" ;; | ||
s390x) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-linux-s390x.tar.gz" ;; | ||
*) echo "Unsupported architecture: ${MACHINE_TYPE}" >&2; exit 1 ;; | ||
esac | ||
;; | ||
darwin) | ||
case "${MACHINE_TYPE}" in | ||
x86_64) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-darwin-x64.tar.gz" ;; | ||
arm64) echo "${NODE_BASE_URL}/node-${NODE_VERSION}-darwin-arm64.tar.gz" ;; | ||
*) echo "Unsupported architecture: ${MACHINE_TYPE}" >&2; exit 1 ;; | ||
esac | ||
;; | ||
*) | ||
echo "Unsupported OS: ${OS_TYPE}" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
# Check if Node.js is globally installed | ||
which node >/dev/null 2>&1 | ||
IS_NODE_GLOBAL=$? | ||
|
||
if [ $isNode -eq 0 ]; then | ||
if [ $IS_NODE_GLOBAL -eq 0 ]; then | ||
node -e "process.exit(Number(process.version.substr(1).split('.')[0]) > 5 ? 0 : 1)" | ||
isNode=$? | ||
IS_NODE_GLOBAL=$? | ||
fi | ||
if [ $isNode -eq 0 ]; then | ||
|
||
if [ $IS_NODE_GLOBAL -eq 0 ]; then | ||
echo "Installer is using your system NodeJS." | ||
echo | ||
node install.js `which node` $1 | ||
node install.js "$(which node)" "$1" | ||
else | ||
MACHINE_TYPE=`uname -m` | ||
echo "Installer is using the embedded NodeJS" | ||
echo | ||
if [[ $OSTYPE == 'darwin'* ]]; then | ||
if [[ $MACHINE_TYPE == 'arm64' ]]; then | ||
../node/arm64/node install.js --add_node $1 | ||
else | ||
../node/x64/node install.js --add_node $1 | ||
fi | ||
elif [ ${MACHINE_TYPE} == 'x86_64' ]; then | ||
../node/x64/node install.js --add_node $1 | ||
else | ||
../node/x86/node install.js --add_node $1 | ||
fi | ||
echo "Node.js not found or version is less than 6. Downloading Node.js..." | ||
mkdir -p "${NODE_INSTALL_DIR}" | ||
|
||
NODE_URL=$(get_node_binary_url) | ||
NODE_ARCHIVE="${NODE_INSTALL_DIR}/node.tar.gz" | ||
|
||
echo "Downloading ${NODE_URL}..." | ||
curl -o "${NODE_ARCHIVE}" "${NODE_URL}" | ||
|
||
echo "Extracting Node.js..." | ||
tar -xzf "${NODE_ARCHIVE}" -C "${NODE_INSTALL_DIR}" --strip-components=1 | ||
rm "${NODE_ARCHIVE}" | ||
|
||
echo "Running installer with embedded Node.js..." | ||
"${NODE_INSTALL_DIR}/bin/node" install.js --add_node "$1" | ||
fi |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.