Skip to content

Commit 7f2ff38

Browse files
designcodeclaude
andauthored
fix: improve update command resolution and restrict brew updates to stable (#87)
* fix: update command resolution * fix: update brew for stable releases only --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e4f6a70 commit 7f2ff38

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
151151
update-homebrew:
152152
needs: [release, build-binaries]
153-
if: needs.release.outputs.new_release_published == 'true'
153+
if: needs.release.outputs.new_release_published == 'true' && github.ref == 'refs/heads/release'
154154
runs-on: ubuntu-latest
155155

156156
steps:

src/utils/update-check.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { execSync } from 'child_process';
2-
import { mkdirSync, readFileSync, writeFileSync } from 'fs';
1+
import { mkdirSync, readFileSync, realpathSync, writeFileSync } from 'fs';
32
import https from 'https';
43
import { homedir } from 'os';
54
import { join } from 'path';
@@ -96,8 +95,8 @@ export function isNewerVersion(current: string, latest: string): boolean {
9695
function isHomebrewInstall(): boolean {
9796
if (process.platform === 'win32') return false;
9897
try {
99-
execSync('brew list tigris', { stdio: 'ignore' });
100-
return true;
98+
const resolved = realpathSync(process.execPath);
99+
return resolved.includes('/Cellar/') || resolved.includes('/Caskroom/');
101100
} catch {
102101
return false;
103102
}
@@ -109,15 +108,23 @@ function isHomebrewInstall(): boolean {
109108
export function getUpdateCommand(): string {
110109
const isBinary =
111110
(globalThis as { __TIGRIS_BINARY?: boolean }).__TIGRIS_BINARY === true;
112-
const isWindows = process.platform === 'win32';
113111

112+
// npm install — process.execPath is Node, not our binary.
113+
// Must come before isHomebrewInstall() to avoid false positives
114+
// when Node itself was installed via Homebrew.
114115
if (!isBinary) {
115116
return 'npm install -g @tigrisdata/cli';
116-
} else if (isHomebrewInstall()) {
117+
}
118+
// Standalone binary installed via Homebrew (execPath resolves to /Cellar/ or /Caskroom/)
119+
else if (isHomebrewInstall()) {
117120
return 'brew upgrade tigris';
118-
} else if (isWindows) {
121+
}
122+
// Standalone binary on Windows
123+
else if (process.platform === 'win32') {
119124
return 'irm https://github.com/tigrisdata/cli/releases/latest/download/install.ps1 | iex';
120-
} else {
125+
}
126+
// Standalone binary on macOS/Linux (installed via curl)
127+
else {
121128
return 'curl -fsSL https://github.com/tigrisdata/cli/releases/latest/download/install.sh | sh';
122129
}
123130
}

0 commit comments

Comments
 (0)