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