Skip to content

Commit 2c6ad85

Browse files
committed
Fix jenv destroy
1 parent 4bc3c69 commit 2c6ad85

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/run-all-unit-tests.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ jobs:
3333
- run: npm ci
3434
- run: npx tsx scripts/cleanup-github-actions.ts
3535

36-
- name: Setup tmate session
37-
uses: mxschmitt/action-tmate@v3
36+
# - name: Setup tmate session
37+
# uses: mxschmitt/action-tmate@v3
3838

3939
- name: Run tests (macOS - zsh login shell)
4040
if: runner.os == 'macOS'
4141
shell: zsh {0}
4242
run: |
4343
sudo chsh -s $(which zsh) $USER
4444
echo $0
45+
46+
# Clean up the residue from the bashrc file
4547
echo $ZSH_NAME $ZSH_VERSION
4648
export SHELL=/bin/zsh
4749
touch ~/.zshrc

src/resources/java/jenv/jenv.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,19 @@ export class JenvResource extends Resource<JenvConfig> {
102102

103103
override async destroy(): Promise<void> {
104104
const $ = getPty();
105-
await $.spawn('rm -rf $HOME/.jenv');
105+
106+
if (Utils.isMacOS()) {
107+
const brewPrefix = await $.spawnSafe('brew --prefix', { interactive: true });
108+
if (brewPrefix.status === SpawnStatus.SUCCESS) {
109+
const jenvPath = await $.spawnSafe('which jenv', { interactive: true });
110+
if (jenvPath.status === SpawnStatus.SUCCESS && jenvPath.data.trim().startsWith(brewPrefix.data.trim())) {
111+
await $.spawn('brew uninstall jenv', { interactive: true });
112+
}
113+
}
114+
await $.spawnSafe('rm -rf $HOME/.jenv');
115+
} else {
116+
await $.spawnSafe('rm -rf $HOME/.jenv');
117+
}
106118

107119
await FileUtils.removeLineFromStartupFile('export PATH="$HOME/.jenv/bin:$PATH"')
108120
await FileUtils.removeLineFromStartupFile('eval "$(jenv init -)"')

0 commit comments

Comments
 (0)