diff --git a/.gitignore b/.gitignore index acd2e8d..885961e 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,9 @@ go.work.sum # Local tools .tools/ + +# Local build output +bin/ + +# Node (optional dev scripts) +node_modules/ diff --git a/README.md b/README.md index 417eb2c..96618b2 100644 --- a/README.md +++ b/README.md @@ -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` diff --git a/package.json b/package.json new file mode 100644 index 0000000..9f4e1f9 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "gogcli", + "private": true, + "scripts": { + "gog": "node scripts/gog.mjs" + } +} diff --git a/scripts/gog.mjs b/scripts/gog.mjs new file mode 100644 index 0000000..d939adc --- /dev/null +++ b/scripts/gog.mjs @@ -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);