harden installers rendering and dependency hygiene
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import { constants } from "node:os";
|
||||
|
||||
import { buildPiArgs, buildPiEnv, type PiRuntimeOptions, resolvePiPaths, toNodeImportSpecifier } from "./runtime.js";
|
||||
import { ensureSupportedNodeVersion } from "../system/node-version.js";
|
||||
|
||||
export function exitCodeFromSignal(signal: NodeJS.Signals): number {
|
||||
const signalNumber = constants.signals[signal];
|
||||
return typeof signalNumber === "number" ? 128 + signalNumber : 1;
|
||||
}
|
||||
|
||||
export async function launchPiChat(options: PiRuntimeOptions): Promise<void> {
|
||||
ensureSupportedNodeVersion();
|
||||
|
||||
@@ -36,11 +42,9 @@ export async function launchPiChat(options: PiRuntimeOptions): Promise<void> {
|
||||
child.on("error", reject);
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
try {
|
||||
process.kill(process.pid, signal);
|
||||
} catch {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
console.error(`feynman terminated because the Pi child exited with ${signal}.`);
|
||||
process.exitCode = exitCodeFromSignal(signal);
|
||||
resolvePromise();
|
||||
return;
|
||||
}
|
||||
process.exitCode = code ?? 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { getFeynmanHome } from "../config/paths.js";
|
||||
|
||||
export type PiWebSearchProvider = "auto" | "perplexity" | "exa" | "gemini";
|
||||
|
||||
@@ -26,8 +27,9 @@ export type PiWebAccessStatus = {
|
||||
note: string;
|
||||
};
|
||||
|
||||
export function getPiWebSearchConfigPath(home = process.env.HOME ?? homedir()): string {
|
||||
return resolve(home, ".feynman", "web-search.json");
|
||||
export function getPiWebSearchConfigPath(home?: string): string {
|
||||
const feynmanHome = home ? resolve(home, ".feynman") : getFeynmanHome();
|
||||
return resolve(feynmanHome, "web-search.json");
|
||||
}
|
||||
|
||||
function normalizeProvider(value: unknown): PiWebSearchProvider | undefined {
|
||||
|
||||
Reference in New Issue
Block a user