UNPKG

@h3ravel/http

Version:

HTTP kernel, middleware pipeline, request/response classes for H3ravel.

31 lines (29 loc) 1.26 kB
import { n as __esm } from "./chunk-BLWcukCW.js"; import { fileURLToPath } from "node:url"; import process from "node:process"; import path from "node:path"; import "node:fs"; import fsPromises from "node:fs/promises"; //#region ../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {}) { let directory = path.resolve(toPath(cwd) ?? ""); const { root } = path.parse(directory); stopAt = path.resolve(directory, toPath(stopAt ?? root)); const isAbsoluteName = path.isAbsolute(name); while (directory) { const filePath = isAbsoluteName ? name : path.join(directory, name); try { const stats = await fsPromises.stat(filePath); if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath; } catch {} if (directory === stopAt || directory === root) break; directory = path.dirname(directory); } } var toPath; var init_find_up_simple = __esm({ "../../node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js": (() => { toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath; }) }); //#endregion init_find_up_simple(); export { findUp };