@vortex.so/cli
Version:
CLI to interact with Vortex.
30 lines (27 loc) • 556 B
JavaScript
import fsp from 'node:fs/promises';
import { dirname } from 'pathe';
import { rimraf } from 'rimraf';
async function exists(path) {
try {
await fsp.access(path);
return true;
} catch {
return false;
}
}
async function clearDir(path) {
await rimraf(path);
await fsp.mkdir(path, { recursive: true });
}
function findup(rootDir, fn) {
let dir = rootDir;
while (dir !== dirname(dir)) {
const res = fn(dir);
if (res) {
return res;
}
dir = dirname(dir);
}
return null;
}
export { clearDir, exists, findup };