define-alpine-the-sequel/helpers/better-api.ts

28 lines
584 B
TypeScript
Raw Permalink Normal View History

2023-02-02 22:02:38 +00:00
import { promisify } from "node:util";
import {
execFile as execFileCallback,
spawn as spawnCallback,
} from "node:child_process";
2023-02-19 20:58:18 +00:00
import { access, stat } from "node:fs/promises";
2023-02-02 22:02:38 +00:00
export const execFile = promisify(execFileCallback);
export const spawn = promisify(spawnCallback);
export async function canAccess(path: string): Promise<boolean> {
try {
await access(path);
return true;
} catch {
return false;
}
}
2023-02-19 20:58:18 +00:00
export async function exists(path: string): Promise<boolean> {
try {
await stat(path);
return true;
} catch {
return false;
}
}