mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 17:01:53 +03:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
+9
-3
@@ -7,15 +7,21 @@ const windowsUncPath = /^\\\\/;
|
||||
|
||||
export function resolveHomeDir(env: Record<string, string | undefined>): string {
|
||||
const home = env.HOME?.trim() || env.USERPROFILE?.trim();
|
||||
if (!home) throw new Error("Missing HOME");
|
||||
if (!home) {
|
||||
throw new Error("Missing HOME");
|
||||
}
|
||||
return home;
|
||||
}
|
||||
|
||||
export function resolveUserPathWithHome(input: string, home?: string): string {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) return trimmed;
|
||||
if (!trimmed) {
|
||||
return trimmed;
|
||||
}
|
||||
if (trimmed.startsWith("~")) {
|
||||
if (!home) throw new Error("Missing HOME");
|
||||
if (!home) {
|
||||
throw new Error("Missing HOME");
|
||||
}
|
||||
const expanded = trimmed.replace(/^~(?=$|[\\/])/, home);
|
||||
return path.resolve(expanded);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user