Skip to content

discoverManifest

Generated reference page for the discoverManifest function export.

Signatures

ts
function discoverManifest(adapter: PackageJsonAdapter, options: ManifestDiscoveryOptions): Promise<PackageJsonData | null>;
ParameterTypeDescription
adapterPackageJsonAdapterAdapter providing readFile + cwd.
optionsManifestDiscoveryOptions = {}Optional anchor (startDir) and candidate filenames (files).

Members

Members

discoverManifest

Discover the nearest manifest (package.json, deno.json, jsr.json, …) by walking up from startDir (or adapter.cwd when omitted).

Convenience helper behind CLIBuilder.manifest(). Most apps should let the CLI runtime discover metadata automatically; call this directly when testing metadata inference or embedding the behavior in custom tooling.

Candidate files are parsed as JSON with a JSONC fallback — package.json, deno.json, jsr.json, and deno.jsonc all qualify, including files that carry // / block comments or trailing commas (common in deno.json). A file that fails both parses is skipped, so discovery keeps probing.

Returns the parsed metadata on success, null when no manifest is found (not an error). Malformed JSON, non-object roots, and config-only manifests that carry no recognised metadata (e.g. a deno.json with only tasks / imports) are all skipped, so discovery keeps probing the remaining candidate files and parent directories — the feature is a convenience, not a hard requirement.

ts
(adapter: PackageJsonAdapter, options: ManifestDiscoveryOptions): Promise<PackageJsonData | null>;

Examples

ts
import { discoverManifest } from '@kjanat/dreamcli';

const meta = await discoverManifest(adapter, { files: ['deno.json', 'jsr.json'] });
if (meta !== null) {
  console.log(meta.version); // '1.2.3'
}

See Also

Released under the MIT License.