@mnrendra/find-up
Version:
A lightweight utility to find a file or directory by searching upward from a specific directory.
1 lines • 1.09 kB
Source Map (JSON)
{"version":3,"file":"index.d.ts","sources":["../src/main.ts"],"sourcesContent":["import { resolve } from 'node:path'\nimport { cwd } from 'node:process'\n\nimport { findUp } from './utils'\n\n/**\n * Finds a file or directory by searching upward from a specific directory.\n *\n * If no initial directory is provided, it will start from the current working\n * directory (`process.cwd()`).\n *\n * @param {string} target - The name of the file or directory to\n * find.\n *\n * @param {string} [initDir] - Optional directory to start searching from.\n * Defaults to `process.cwd()`.\n *\n * @returns {string|null} The absolute path of the file or directory if found,\n * or `null` if not found.\n *\n * @see {@link https://github.com/mnrendra/find-up#findup documentation}\n */\nconst main = (\n target: string,\n initDir: string = cwd()\n): string | null => {\n const path = resolve(initDir, target)\n\n return findUp(path, target)\n}\n\nexport default main\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAA,IAAA;;;;"}