From 72605114e301d12f4578b2f7620b23c74128dfbd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 22:27:50 +0300 Subject: [PATCH] Add support for installing Node.js on macOS (#38903) (#38909) This commit adds two new functions in `install_macos_tools.sh` that install nodejs and common nodejs dependencies. (cherry picked from commit 8f86989290529604fb3a7820449ab867dd12b373) Co-authored-by: Dimitrios Liappis --- .buildkite/scripts/install_macos_tools.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.buildkite/scripts/install_macos_tools.sh b/.buildkite/scripts/install_macos_tools.sh index c9d27cbc9dbc..124025b4a5ad 100755 --- a/.buildkite/scripts/install_macos_tools.sh +++ b/.buildkite/scripts/install_macos_tools.sh @@ -106,6 +106,28 @@ config_git() { fi } +withNodeJSEnv() { + local version=$1 + echo "~~~ Installing nvm and Node.js" + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" + echo "Installing Node.js version: $version" + nvm install "$version" + # export PATH="${nvmPath}:${PATH}" + nvm use "$version" + node --version + echo "~~~ Resuming commands" +} + +installNodeJsDependencies() { + echo "~~~ Installing Node.js packages" + # needed for beats-xpack-heartbeat + echo "Install @elastic/synthetics" + npm i -g @elastic/synthetics + echo "~~~ Resuming commands" +} + add_bin_path with_go "${GO_VERSION}" with_mage