mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-12-02 02:33:10 +08:00
23 lines
649 B
TypeScript
23 lines
649 B
TypeScript
import { homedir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
export function resolveDevelopmentAppDataRoot(
|
|
platform: NodeJS.Platform = process.platform,
|
|
environment: NodeJS.ProcessEnv = process.env,
|
|
homeDirectory = homedir(),
|
|
): string {
|
|
if (platform === "darwin") {
|
|
return join(homeDirectory, "Library", "Application Support");
|
|
}
|
|
|
|
if (platform === "win32") {
|
|
const appData = environment.APPDATA?.trim();
|
|
if (!appData) {
|
|
throw new Error("APPDATA is not set. OpenBot dev state was not changed.");
|
|
}
|
|
return appData;
|
|
}
|
|
|
|
return environment.XDG_CONFIG_HOME?.trim() || join(homeDirectory, ".config");
|
|
}
|