node-ejs-renderer/node_modules/pkg-dir/index.js

13 lines
380 B
JavaScript
Raw Permalink Normal View History

2024-06-09 13:55:01 -04:00
import path from 'node:path';
import {findUp, findUpSync} from 'find-up';
export async function packageDirectory({cwd} = {}) {
const filePath = await findUp('package.json', {cwd});
return filePath && path.dirname(filePath);
}
export function packageDirectorySync({cwd} = {}) {
const filePath = findUpSync('package.json', {cwd});
return filePath && path.dirname(filePath);
}