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

28 lines
584 B
TypeScript

import { promisify } from "node:util";
import {
execFile as execFileCallback,
spawn as spawnCallback,
} from "node:child_process";
import { access, stat } from "node:fs/promises";
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;
}
}
export async function exists(path: string): Promise<boolean> {
try {
await stat(path);
return true;
} catch {
return false;
}
}