@equinor/fusion-framework-cli
Version:
Command-line toolkit for developing, building, and publishing Fusion Framework applications and portal templates. Provides a unified developer experience from local development to production deployment.
27 lines • 1.16 kB
JavaScript
import { dirname } from 'node:path';
import { readPackageUp, } from 'read-package-up';
import normalizePackageData from 'normalize-package-data'; // Correct import for normalize-package-data
/**
* Resolves the application package by searching for the nearest `package.json` file.
*
* @param options - Optional parameters to customize the search behavior.
* @returns A promise that resolves to the found package information.
* @throws Will throw an error if the `package.json` file is not found.
*/
export const resolvePackage = async (options) => {
const pkg = await readPackageUp({ ...options, normalize: false });
if (!pkg) {
throw new Error('failed to find package.json');
}
// normalizePackageData mutates its argument and returns void, so clone first
const normalizedPackageJson = { ...pkg.packageJson };
normalizePackageData(normalizedPackageJson);
const packageJson = { ...normalizedPackageJson, version: pkg.packageJson.version };
return {
packageJson,
path: pkg.path,
root: dirname(pkg.path),
};
};
export default resolvePackage;
//# sourceMappingURL=resolve-package.js.map