Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,30 @@ echo "Installing nvm in $NVM_DIR"

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | PROFILE=/dev/null bash

# DIAGNOSTIC v3 (temporary): bisect where the Windows hang is. A padding block
# fills the stdio buffer (which never flushes while the process hangs), forcing
# a flush BEFORE each risky step so a later hang can't erase earlier readings.
# Search the log for "[diag]". The last [diag] STAGE seen pinpoints the hang.
diag_flush() { awk 'BEGIN { for (i = 0; i < 4000; i++) print "[pad] flush " i }'; }
diag_trim_noop() { [ "${PWD%/*}" = "$PWD" ] && echo YES || echo NO; }

printf '[diag] STAGE raw: PWD=%s trim-noop=%s\n' "$PWD" "$(diag_trim_noop)"
printf '[diag] STAGE about-to-normalize\n'
diag_flush

nvm_plugin_normalize_windows_pwd_for_nvm
printf '[diag] STAGE normalized: PWD=%s trim-noop=%s\n' "$PWD" "$(diag_trim_noop)"
printf '[diag] STAGE about-to-source\n'
diag_flush

# shellcheck source=/dev/null
source "$NVM_DIR/nvm.sh" --no-use
printf '[diag] STAGE sourced-ok\n'
diag_flush

printf '[diag] STAGE all-clear: neither normalize nor source hung\n'
return 0

echo "~~~ :node: Installing Node.js"
install_args=("--no-progress")
if [[ -n ${BUILDKITE_PLUGIN_NVM_VERSION:-} ]]; then
echo "Installing Node.js version ${BUILDKITE_PLUGIN_NVM_VERSION}"
install_args+=("${BUILDKITE_PLUGIN_NVM_VERSION}")
else
echo "Installing Node.js version specified in the .nvmrc file"
fi
nvm install "${install_args[@]}"

echo "~~~ :node: Activating Node.js"
Expand Down