UNPKG

@vortex.so/cli

Version:

CLI to interact with Vortex.

38 lines (32 loc) 827 B
'use strict'; const fsp = require('node:fs/promises'); const pathe = require('pathe'); const rimraf = require('rimraf'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const fsp__default = /*#__PURE__*/_interopDefaultCompat(fsp); async function exists(path) { try { await fsp__default.access(path); return true; } catch { return false; } } async function clearDir(path) { await rimraf.rimraf(path); await fsp__default.mkdir(path, { recursive: true }); } function findup(rootDir, fn) { let dir = rootDir; while (dir !== pathe.dirname(dir)) { const res = fn(dir); if (res) { return res; } dir = pathe.dirname(dir); } return null; } exports.clearDir = clearDir; exports.exists = exists; exports.findup = findup;