fix: use owner-level unidesk state
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, isAbsolute, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export interface UniDeskConfig {
|
||||
@@ -101,8 +102,14 @@ export interface UniDeskMicroserviceConfig {
|
||||
|
||||
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
||||
export const repoRoot = join(moduleDir, "..", "..");
|
||||
export const stateRoot = join(homedir(), ".unidesk", ".state");
|
||||
|
||||
export function rootPath(...parts: string[]): string {
|
||||
const first = parts[0];
|
||||
if (first === undefined) return repoRoot;
|
||||
if (isAbsolute(first)) return join(first, ...parts.slice(1));
|
||||
if (first === ".state") return join(stateRoot, ...parts.slice(1));
|
||||
if (first.startsWith(".state/")) return join(stateRoot, first.slice(".state/".length), ...parts.slice(1));
|
||||
return join(repoRoot, ...parts);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user