import type { AbsolutePath } from '@-xun/fs'; import type { XPackageJson } from '@-xun/project-types'; import type { EmptyObject } from 'type-fest'; /** * @see {@link readXPackageJsonAtRoot} */ export type ReadXPackageJsonAtRootOptions = { /** * Use the internal cached result from a previous run, if available. * * The caching behavior of this function is identical to that of * {@link readJson}. */ useCached: boolean; /** * If `true`, an attempt will be made to read in and parse the JSON file. If * it fails (i.e. an error is thrown), `{}` is returned and no error is * thrown. * * Note that, currently, fail results (where `{}` is returned) are not cached. * * @default false */ try?: boolean; }; /** * Asynchronously read in and parse the contents of a package.json file. * * **NOTE: the result of this function is memoized! This does NOT _necessarily_ * mean results will strictly equal each other. See `useCached` in this specific * function's options for details.** To fetch fresh results, set the `useCached` * option to `false` or clear the internal cache with `cache.clear`. * * @see {@link readJson} (the function that actually does the reading/caching) */ export declare function readXPackageJsonAtRoot(path: AbsolutePath, options: ReadXPackageJsonAtRootOptions & { try?: false; }): Promise; export declare function readXPackageJsonAtRoot(path: AbsolutePath, options: ReadXPackageJsonAtRootOptions): Promise; export declare namespace readXPackageJsonAtRoot { /** * Synchronously read in and parse the contents of a package.json file. * * **NOTE: the result of this function is memoized! This does NOT * _necessarily_ mean results will strictly equal each other. See `useCached` * in this specific function's options for details.** To fetch fresh results, * set the `useCached` option to `false` or clear the internal cache with * `cache.clear`. * * @see {@link readJson} (the function that actually does the reading/caching) */ function readXPackageJsonAtRootSync(path: AbsolutePath, options: ReadXPackageJsonAtRootOptions & { try?: false; }): XPackageJson; function readXPackageJsonAtRootSync(path: AbsolutePath, options: ReadXPackageJsonAtRootOptions): XPackageJson | EmptyObject; export const sync: typeof readXPackageJsonAtRootSync; export {}; }