30 lines
617 B
TypeScript
30 lines
617 B
TypeScript
export async function checkIfFileExists(filePath: string): boolean {
|
|
try {
|
|
await Deno.lstat(filePath);
|
|
return true;
|
|
} catch (error) {
|
|
if (error instanceof Deno.errors.NotFound) {
|
|
return false;
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function createSubtrTmpDirectories(): void {
|
|
const dirs = [
|
|
"/tmp/substr/img/"
|
|
]
|
|
|
|
for (const path of dirs) {
|
|
await Deno.mkdir(path, { recursive: true });
|
|
}
|
|
}
|
|
|
|
export async function runCommand(command) {
|
|
const process = Deno.run({ cmd: command });
|
|
const status = await process.status();
|
|
process.close();
|
|
return status;
|
|
}
|