mirror of
https://github.com/googleworkspace/cli.git
synced 2026-09-14 16:47:13 +08:00
6ccbb42650
* 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>
37 lines
852 B
JavaScript
37 lines
852 B
JavaScript
#!/usr/bin/env node
|
|
|
|
"use strict";
|
|
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
const { spawnSync } = require("child_process");
|
|
const { getPlatform } = require("./platform");
|
|
|
|
const platform = getPlatform();
|
|
const binPath = path.join(__dirname, "bin", platform.binary);
|
|
|
|
if (!fs.existsSync(binPath)) {
|
|
console.error(
|
|
`gws binary not found at ${binPath}\nAuto-installing...`
|
|
);
|
|
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), {
|
|
cwd: process.cwd(),
|
|
stdio: "inherit",
|
|
});
|
|
|
|
if (result.error) {
|
|
console.error(`Error running gws: ${result.error.message}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
process.exit(result.status ?? 1);
|