UNPKG

380 BJavaScriptView Raw
1import path from 'node:path';
2import {findUp, findUpSync} from 'find-up';
3
4export async function packageDirectory({cwd} = {}) {
5 const filePath = await findUp('package.json', {cwd});
6 return filePath && path.dirname(filePath);
7}
8
9export function packageDirectorySync({cwd} = {}) {
10 const filePath = findUpSync('package.json', {cwd});
11 return filePath && path.dirname(filePath);
12}