Add pnpm gog build+run shortcut
This commit is contained in:
parent
bfbc6e4323
commit
e494764f9b
6
.gitignore
vendored
6
.gitignore
vendored
@ -33,3 +33,9 @@ go.work.sum
|
||||
|
||||
# Local tools
|
||||
.tools/
|
||||
|
||||
# Local build output
|
||||
bin/
|
||||
|
||||
# Node (optional dev scripts)
|
||||
node_modules/
|
||||
|
||||
@ -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
7
package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "gogcli",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"gog": "node scripts/gog.mjs"
|
||||
}
|
||||
}
|
||||
25
scripts/gog.mjs
Normal file
25
scripts/gog.mjs
Normal 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);
|
||||
Loading…
Reference in New Issue
Block a user