Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hooks): paths vars not exported properly in fish #34

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
if: "${{ matrix.os == 'macos-latest' }}"
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
path: ${{ env.GHJK_DENO_DIR }}
key: deno-mac-${{ hashFiles('**/deno.lock') }}

- if: "${{ matrix.e2eType == 'docker' }}"
Expand Down
1 change: 1 addition & 0 deletions install/ghjk.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
export GHJK_SHARE_DIR="${GHJK_SHARE_DIR:-__GHJK_SHARE_DIR__}"
export DENO_DIR="${GHJK_DENO_DIR:-__DENO_CACHE_DIR}"
export DENO_NO_UPDATE_CHECK=1

# if ghjkfile var is set, set the GHJK_DIR overriding
# any set by the user
Expand Down
1 change: 0 additions & 1 deletion install/hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export GHJK_LAST_PWD="$PWD"

precmd() {
if [ "$GHJK_LAST_PWD" != "$PWD" ]; then
echo "reloading"
ghjk_reload
export GHJK_LAST_PWD="$PWD"
fi
Expand Down
4 changes: 2 additions & 2 deletions modules/ports/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,8 @@ export ${k}="${v}:$${k}";
set --global --export ${k} '${v}';`
),
...Object.entries(pathVars).map(([k, v]) =>
`set --global --append GHJK_CLEANUP_FISH 'set --global --path ${k} (string match --invert --regex "^${envDir}" $${k});';
set --global --prepend ${k} ${v};
`set --global --append GHJK_CLEANUP_FISH 'set --global --export --path ${k} (string match --invert --regex "^${envDir}" $${k});';
set --global --export --prepend ${k} ${v};
`
),
].join("\n"),
Expand Down
14 changes: 12 additions & 2 deletions tests/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import {
import dummy from "../ports/dummy.ts";
import type { InstallConfigFat } from "../port.ts";

// avoid using single quotes in this script
const posixInteractiveScript = `
set -eux
[ "$DUMMY_ENV" = "dummy" ] || exit 101
dummy

# it should be avail in subshells
sh -c '[ "$DUMMY_ENV" = "dummy" ]' || exit 105
sh -c "dummy"

pushd ../
# it shouldn't be avail here
[ $(set +e; dummy) ] && exit 102
Expand Down Expand Up @@ -59,7 +62,6 @@ ${line}
]
.join("\n");

// avoid using single quotes in this script
const posixNonInteractiveScript = `
set -eux

Expand All @@ -68,6 +70,10 @@ ghjk_reload
[ "$DUMMY_ENV" = "dummy" ] || exit 101
dummy

# it should be avail in subshells
sh -c '[ "$DUMMY_ENV" = "dummy" ]' || exit 105
sh -c "dummy"

pushd ../
# no reload so it's stil avail
dummy
Expand All @@ -94,6 +100,10 @@ const fishScript = `
dummy; or exit 101
test $DUMMY_ENV = "dummy"; or exit 102

# it should be avail in subshells
sh -c '[ "$DUMMY_ENV" = "dummy" ]'; or exit 105
sh -c "dummy"

pushd ../
# it shouldn't be avail here
which dummy; and exit 103
Expand Down
Loading