discoverPackageJson
Generated reference page for the discoverPackageJson function export.
- Import:
@kjanat/dreamcli - Export kind: function
- Declared in:
src/core/config/package-json.ts - Source link:
packages/dreamcli/src/core/config/package-json.ts:109
Signatures
ts
function discoverPackageJson(adapter: PackageJsonAdapter): Promise<PackageJsonData | null>;Members
Members
discoverPackageJson
Discover the nearest package.json by walking up from adapter.cwd.
Convenience helper behind CLIBuilder.packageJson(). Most apps should let the CLI runtime discover package metadata automatically; call this directly when testing metadata inference or embedding the behavior in custom tooling.
Returns the parsed metadata on success, null when no package.json is found (not an error). Malformed JSON and non-object roots also return null — the feature is a convenience, not a hard requirement.
ts
(adapter: PackageJsonAdapter): Promise<PackageJsonData | null>;Examples
ts
import { discoverPackageJson } from '@kjanat/dreamcli';
const pkg = await discoverPackageJson(adapter);
if (pkg !== null) {
console.log(pkg.version); // '1.2.3'
}