@darkobits/saffron
Version:
Yargs + Cosmiconfig for robust, configurable CLIs.
33 lines (32 loc) • 1 kB
TypeScript
import { type NormalizedPackageJson } from 'read-pkg-up';
/**
* Object returned by `getPackageInfo`.
*/
export interface PackageInfo {
json: NormalizedPackageJson | undefined;
root: string | undefined;
}
interface GetPackageInfoOptions {
cwd: string;
}
/**
* Loads the package.json of the host or local package and returns the
* normalized result and the package's root directory. Results are cached.
*
* - For the manifest of the project running the CLI use `process.cwd()`.
* - For the manifest of the project implementing the CLI, use
* `path.dirname(fs.realpathSync(process.argv[1]))`.
*/
export declare function getPackageInfo({ cwd }: GetPackageInfoOptions): PackageInfo;
type ParsedPackageName<T> = T extends string ? {
scope: string | undefined;
name: string;
} : {
scope: undefined;
name: undefined;
};
export declare function parsePackageName<T = any>(packageName: T): ParsedPackageName<T> | {
scope: undefined;
name: T & string;
};
export {};