Add pnpm gog build+run shortcut

This commit is contained in:
Peter Steinberger 2025-12-12 14:24:29 +00:00
parent bfbc6e4323
commit e494764f9b
4 changed files with 44 additions and 0 deletions

6
.gitignore vendored
View File

@ -33,3 +33,9 @@ go.work.sum
# Local tools
.tools/
# Local build output
bin/
# Node (optional dev scripts)
node_modules/

View File

@ -36,3 +36,9 @@ Run smoke tests against real APIs (not in CI):
- Format: `make fmt`
- Lint: `make lint`
- Test: `make test`
### `pnpm` shortcut
If you use `pnpm`, you can build+run in one step:
- `pnpm gog auth add you@gmail.com`

7
package.json Normal file
View File

@ -0,0 +1,7 @@
{
"name": "gogcli",
"private": true,
"scripts": {
"gog": "node scripts/gog.mjs"
}
}

25
scripts/gog.mjs Normal file
View File

@ -0,0 +1,25 @@
import { mkdirSync } from "node:fs";
import { join } from "node:path";
import { spawnSync } from "node:child_process";
function run(cmd, args) {
const res = spawnSync(cmd, args, { stdio: "inherit" });
if (res.error) throw res.error;
if (res.status !== 0) {
process.exit(typeof res.status === "number" ? res.status : 1);
}
return res.status;
}
const repoRoot = process.cwd();
const binDir = join(repoRoot, "bin");
mkdirSync(binDir, { recursive: true });
const exe = process.platform === "win32" ? "gog.exe" : "gog";
const binPath = join(binDir, exe);
run("go", ["build", "-o", binPath, "./cmd/gog"]);
const final = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
if (final.error) throw final.error;
process.exit(typeof final.status === "number" ? final.status : 1);