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>
This commit is contained in:
Justin Poehnelt
2026-03-31 11:47:43 -06:00
committed by GitHub
parent 5d24ac225b
commit 6ccbb42650
2 changed files with 17 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
---
"@googleworkspace/cli": patch
---
fix: auto-install binary on run if missing
pnpm skips postinstall when the package is already up to date.
This ensures run.js will auto-trigger install.js if the
binary is missing, fixing the 'gws binary not found' error.
+8 -2
View File
@@ -12,9 +12,15 @@ const binPath = path.join(__dirname, "bin", platform.binary);
if (!fs.existsSync(binPath)) {
console.error(
`gws binary not found at ${binPath}\nRun "npm install -g @googleworkspace/cli" to install it.`,
`gws binary not found at ${binPath}\nAuto-installing...`
);
process.exit(1);
const install = spawnSync(process.execPath, [path.join(__dirname, "install.js")], {
cwd: __dirname,
stdio: "inherit",
});
if (install.status !== 0) {
process.exit(install.status ?? 1);
}
}
const result = spawnSync(binPath, process.argv.slice(2), {