Compare commits

...

3 Commits

Author SHA1 Message Date
Steven Dee (Jōshin)
dd19514c30
Merge c1064550872bfc16afe02ec6edeb73ff3847a3da into 9a28dbd394043645943230dfa07f9c2c24358f32 2024-08-31 18:03:17 +12:00
Jordan Harband
9a28dbd394
[actions] use node/install instead of node/run 2024-08-28 11:28:52 -07:00
Jōshin
c106455087
[Fix] install.sh: install looks for .zshenv
A zsh user may have set `ZDOTDIR` to something other than `$HOME`, in which case the profile and rc files will not be located under `$HOME`. But unless the system `zshenv` has done something unusual, it is usually a safe bet that there will be a `$HOME/.zshenv` that, if nothing else, will be setting up `ZDOTDIR`.
2024-05-30 11:58:37 -07:00
3 changed files with 36 additions and 25 deletions

View File

@ -58,12 +58,11 @@ jobs:
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
- run: curl --version
- run: wget --version
- uses: ljharb/actions/node/run@main
- uses: ljharb/actions/node/install@main
name: 'npm install && version checks'
with:
node-version: 'lts/*'
skip-ls-check: true
shell-command: echo installed
- run: npm ls urchin
- run: npx which urchin
- run: env

View File

@ -40,7 +40,7 @@ nvm_profile_is_bash_or_zsh() {
local TEST_PROFILE
TEST_PROFILE="${1-}"
case "${TEST_PROFILE-}" in
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc" | *"/.zprofile")
*"/.bashrc" | *"/.bash_profile" | *"/.zshenv" | *"/.zshrc" | *"/.zprofile")
return
;;
*)
@ -300,11 +300,13 @@ nvm_detect_profile() {
DETECTED_PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.zprofile" ]; then
DETECTED_PROFILE="$HOME/.zprofile"
elif [ -f "$HOME/.zshenv" ]; then
DETECTED_PROFILE="$HOME/.zshenv"
fi
fi
if [ -z "$DETECTED_PROFILE" ]; then
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".zshenv"
do
if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then
break

View File

@ -2,11 +2,11 @@
# Save the PATH as it was when the test started to restore it when it
# finishes
ORIG_PATH=$PATH
ORIG_PATH="${PATH}"
cleanup() {
# Restore the PATH as it was when the test started
export PATH=ORIG_PATH
export PATH="${ORIG_PATH}"
}
die () { cleanup; echo "$@" ; exit 1; }
@ -15,20 +15,23 @@ die () { cleanup; echo "$@" ; exit 1; }
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are
# located
MOCKS_DIR=`pwd`/../../mocks
MOCKS_DIR="$(pwd)/../../mocks"
# Sets the PATH for these tests to include the symlinks to the mocked
# binaries
export PATH=.:${PATH}
export PATH=".:${PATH}"
# Setups mock binaries for a given OS and arch that mimic
# the output of the real binaries used by nvm_get_arch to guess
# the architecture of a given system.
setup_mock_arch() {
local OS=$1
local ARCH=$2
local OPT=$3
local OS
OS=$1
local ARCH
ARCH=$2
local OPT
OPT=$3
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
if [ "_${OS}" = '_solaris' ] || [ "_${OS}" = '_smartos' ]; then
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
if [ "_$OPT" != "_no_pkg_info" ]; then
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
@ -42,10 +45,12 @@ setup_mock_arch() {
# Cleans up the setup done by setup_mock_arch.
cleanup_mock_arch() {
local OS=$1
local ARCH=$2
local OS
OS=$1
local ARCH
ARCH=$2
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
if [ "_${OS}" = '_solaris' ] || [ "_${OS}" = '_smartos' ]; then
rm -f ./isainfo
rm -f ./pkg_info
fi
@ -57,17 +62,22 @@ cleanup_mock_arch() {
# expected output $EXPECTED_OUTPUT with the actual output. Does nothing
# and exits cleanly if they match, dies otherwise.
run_test() {
local ARCH=$1
local OS=$2
local EXPECTED_OUTPUT=$3
local OPT=$4
local ARCH
ARCH=$1
local OS
OS=$2
local EXPECTED_OUTPUT
EXPECTED_OUTPUT=$3
local OPT
OPT=$4
setup_mock_arch $OS $ARCH $OPT
local OUTPUT="$(nvm_get_arch)"
cleanup_mock_arch $OS $ARCH
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] ||
die "nvm_get_arch for OS \"$OS\" and arch \"$ARCH\" with OPT \"$OPT\" did
not return \"$EXPECTED_OUTPUT\"; got \"$OUTPUT\""
setup_mock_arch "${OS}" "${ARCH}" "${OPT}"
local OUTPUT
OUTPUT="$(nvm_get_arch)"
cleanup_mock_arch "${OS}" "${ARCH}"
[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] ||
die "nvm_get_arch for OS \"${OS}\" and arch \"${ARCH}\" with OPT \"${OPT}\" did
not return \"${EXPECTED_OUTPUT}\"; got \"${OUTPUT}\""
}
run_test x86 smartos x86