Skip to content

Commit

Permalink
Don’t allow dev to be activate twice (pkgxdev#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl authored Sep 12, 2023
1 parent 136ab36 commit 3cd048e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/ci.shellcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,14 @@ jobs:
no-shell-output-if-no-tty:
needs: compile
runs-on: ubuntu-latest
container:
image: archlinux:latest # lazygit fails for reasons that are mysterious
options: -t
steps:
- uses: actions/download-artifact@v3
with:
path: /usr/local/bin
name: tea

- name: prep
run: |
chmod u+x /usr/local/bin/tea
run: chmod u+x /usr/local/bin/tea

#TODO ideally we'd test something that uses another tool in tea and
# is poorly written so it reads both stdout and stderr eg `lazygit`
Expand All @@ -361,6 +357,29 @@ jobs:
tea echo 2> >(tee temp_file) >/dev/null
if [[ -s temp_file ]]; then
echo
echo 'tea output logging info when no tty present'
echo 'tea output logging info when no tty present' >&2
exit 1
fi
cannot-multi-dev:
needs: compile
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: /usr/local/bin
name: tea
- name: prep
run: chmod u+x /usr/local/bin/tea

- run: echo '{}' > package.json

- run: |
eval "$(tea --shellcode)"
dev
if dev; then
echo 'dev did not fail when already activated' >&2
exit 1
fi
3 changes: 3 additions & 0 deletions src/modes/shellcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default function() {
dev() {
if [ "$1" = 'off' ]; then
_tea_deactivate
elif type _tea_deactivate >/dev/null 2>&1; then
echo 'dev: environment already active' >&2
return 1
else
eval "$(command tea --internal.activate "$PWD" "$@")"
fi
Expand Down

0 comments on commit 3cd048e

Please sign in to comment.