open-code-review/bin/ocr.js
Bison Xu 89effb6b22
feat(build): add Windows platform support (#13)
* feat(build): add Windows platform support

Add windows/amd64 and windows/arm64 to CI build matrix, Makefile
cross-platform targets, and handle .exe suffix in install/update
scripts and binary wrapper. Skip chmod on Windows where unsupported.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs(README): add Windows download instructions

Add Windows x86_64 and ARM64 binary download commands to both
English and Chinese README install sections.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 21:57:31 +08:00

40 lines
1.2 KiB
JavaScript
Executable file

#!/usr/bin/env node
"use strict";
const { spawnSync, spawn } = require("child_process");
const path = require("path");
const fs = require("fs");
const os = require("os");
const IS_WINDOWS = process.platform === "win32";
const binaryPath = path.join(__dirname, IS_WINDOWS ? "opencodereview.exe" : "opencodereview");
if (!process.env.OCR_NO_UPDATE) {
const stateDir = path.join(os.homedir(), ".opencodereview");
const tsFile = path.join(stateDir, "last-update-check");
const cooldownMs =
(parseInt(process.env.OCR_UPDATE_INTERVAL, 10) || 30) * 60 * 1000;
let shouldCheck = true;
try {
const mt = fs.statSync(tsFile).mtimeMs;
if (Date.now() - mt < cooldownMs) shouldCheck = false;
} catch (_) {}
if (shouldCheck) {
const updateScript = path.join(__dirname, "..", "scripts", "update.js");
const child = spawn(process.execPath, [updateScript], {
detached: true,
stdio: "ignore",
env: Object.assign({}, process.env, { OCR_NO_UPDATE: "1" }),
});
child.unref();
}
}
const result = spawnSync(binaryPath, process.argv.slice(2), {
stdio: "inherit",
env: process.env,
});
process.exit(result.status ?? (result.error ? 1 : 0));