mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 02:59:35 +00:00
feat: integrate Pi backend and Pi Web
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { parseArgs } = require("util");
|
||||
|
||||
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
|
||||
|
||||
function isEnabled(value) {
|
||||
return typeof value === "string" && TRUE_VALUES.has(value.trim().toLowerCase());
|
||||
}
|
||||
|
||||
function parseLaunchOptions(args = process.argv.slice(2), env = process.env) {
|
||||
const { values: cliArgs } = parseArgs({
|
||||
args,
|
||||
options: {
|
||||
port: { type: "string", short: "p" },
|
||||
hostname: { type: "string", short: "H" },
|
||||
"no-open": { type: "boolean" },
|
||||
},
|
||||
strict: false,
|
||||
});
|
||||
|
||||
return {
|
||||
port: cliArgs.port ?? env.PORT ?? "30141",
|
||||
hostname: cliArgs.hostname ?? env.PI_WEB_HOSTNAME ?? "127.0.0.1",
|
||||
openBrowser: !cliArgs["no-open"] && !isEnabled(env.PI_WEB_NO_OPEN),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { parseLaunchOptions };
|
||||
Reference in New Issue
Block a user