update deno commons mod
This commit is contained in:
@@ -115,9 +115,9 @@ export async function execCommandShell(
|
|||||||
shell: false,
|
shell: false,
|
||||||
stdio: ["inherit", "inherit", "inherit"],
|
stdio: ["inherit", "inherit", "inherit"],
|
||||||
});
|
});
|
||||||
ps.on('close', (code) => {
|
ps.on("close", (code) => {
|
||||||
resolve(code);
|
resolve(code);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ export function parseIntVal(val: any, defaultVal: number): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getEnv(envKey: string): string | null {
|
export function getEnv(envKey: string): string | null {
|
||||||
const homeDir = getHomeDir();
|
const homeDir = homeDir();
|
||||||
if ((homeDir !== null) && envKey) {
|
if ((homeDir !== null) && envKey) {
|
||||||
const envValue = readFileToStringSync(
|
const envValue = readFileToStringSync(
|
||||||
`${homeDir}/.config/envs/${envKey}`,
|
`${homeDir}/.config/envs/${envKey}`,
|
||||||
@@ -653,7 +653,11 @@ class Logger {
|
|||||||
export const log = new Logger();
|
export const log = new Logger();
|
||||||
|
|
||||||
export function getHomeDirOrDie(): string {
|
export function getHomeDirOrDie(): string {
|
||||||
const homeDir = getHomeDir();
|
return homeDirOrDie();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function homeDirOrDie(): string {
|
||||||
|
const homeDir = homeDir();
|
||||||
if (homeDir === null) {
|
if (homeDir === null) {
|
||||||
throw new Error("Cannot find home dir");
|
throw new Error("Cannot find home dir");
|
||||||
}
|
}
|
||||||
@@ -661,6 +665,10 @@ export function getHomeDirOrDie(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getHomeDir(): string | null {
|
export function getHomeDir(): string | null {
|
||||||
|
return homeDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function homeDir(): string | null {
|
||||||
// if (Deno.build.os === "windows") {
|
// if (Deno.build.os === "windows") {
|
||||||
// const userProfile = Deno.env.get("USERPROFILE");
|
// const userProfile = Deno.env.get("USERPROFILE");
|
||||||
// if (userProfile) {
|
// if (userProfile) {
|
||||||
@@ -673,12 +681,12 @@ export function getHomeDir(): string | null {
|
|||||||
// }
|
// }
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
return osEnv("HOME") || null;
|
return osEnv("HOME") ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveFilename(filename: string): string {
|
export function resolveFilename(filename: string): string {
|
||||||
if (filename.startsWith("~/")) {
|
if (filename.startsWith("~/")) {
|
||||||
return getHomeDir() + filename.substring(1);
|
return homeDir() + filename.substring(1);
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user