pi-mono/apps/p2/scripts/reload.mjs
Mario Zechner 05dc8d239d feat: add apps/p2 (imported from pi-private at 7dadff697)
p2 (Pi Mobile on Chord v2) moves from pi-private into pi as one commit. Root scripts that loop all workspaces
use --if-present; npm test, ./test.sh and the release script cover packages/* only (p2: cd apps/p2 && npm test);
sync-versions also updates apps' workspace pins.
2026-11-03 13:39:06 +00:00

19 lines
812 B
JavaScript

import { homedir } from "node:os";
import { join } from "node:path";
import { sendDevCommand } from "../src/hosts/dev-channel.ts";
import { parseDevCommand } from "../src/runtime/dev-protocol.ts";
try {
const args = process.argv.slice(2);
if (args.includes("--restart") && args.length !== 1)
throw new Error("--restart cannot be combined with plugin names");
const command = parseDevCommand(
args[0] === "--restart" ? { action: "restart" } : { action: "reload", ...(args.length ? { plugins: args } : {}) },
);
const result = await sendDevCommand(process.env.P2_DATA_DIR ?? join(homedir(), ".pi", "p2"), command);
console[result.ok ? "log" : "error"](result.message);
if (!result.ok) process.exitCode = 1;
} catch (error) {
console.error(`Reload refused: ${error.message}`);
process.exitCode = 1;
}