Skip to content

Commit 6ccbb42

Browse files
fix: auto-install binary on run if missing (#654)
* fix: auto-install binary on run if missing pnpm skips postinstall when the package is already cached/installed. This commit ensures run.js will auto-trigger install.js if the binary is missing, fixing the 'gws binary not found' error. * chore: add changeset for pnpm binary fix --------- Co-authored-by: jpoehnelt-bot <jpoehnelt-bot@users.noreply.github.com>
1 parent 5d24ac2 commit 6ccbb42

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@googleworkspace/cli": patch
3+
---
4+
5+
fix: auto-install binary on run if missing
6+
7+
pnpm skips postinstall when the package is already up to date.
8+
This ensures run.js will auto-trigger install.js if the
9+
binary is missing, fixing the 'gws binary not found' error.

npm/run.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ const binPath = path.join(__dirname, "bin", platform.binary);
1212

1313
if (!fs.existsSync(binPath)) {
1414
console.error(
15-
`gws binary not found at ${binPath}\nRun "npm install -g @googleworkspace/cli" to install it.`,
15+
`gws binary not found at ${binPath}\nAuto-installing...`
1616
);
17-
process.exit(1);
17+
const install = spawnSync(process.execPath, [path.join(__dirname, "install.js")], {
18+
cwd: __dirname,
19+
stdio: "inherit",
20+
});
21+
if (install.status !== 0) {
22+
process.exit(install.status ?? 1);
23+
}
1824
}
1925

2026
const result = spawnSync(binPath, process.argv.slice(2), {

0 commit comments

Comments
 (0)