epiphany/node_modules/read-pkg-up/index.js
2023-12-09 22:48:07 -08:00

27 lines
614 B
JavaScript

import path from 'path';
import findUp from 'find-up';
import {readPackageAsync, readPackageSync} from 'read-pkg';
export async function readPackageUpAsync(options) {
const filePath = await findUp('package.json', options);
if (!filePath) {
return;
}
return {
packageJson: await readPackageAsync({...options, cwd: path.dirname(filePath)}),
path: filePath
};
}
export function readPackageUpSync(options) {
const filePath = findUp.sync('package.json', options);
if (!filePath) {
return;
}
return {
packageJson: readPackageSync({...options, cwd: path.dirname(filePath)}),
path: filePath
};
}