Skip to content

inferCliName

Generated reference page for the inferCliName function export.

Signatures

ts
function inferCliName(pkg: PackageJsonData, options: { stripScope?: boolean; }): string | undefined;
ParameterTypeDescription
pkgPackageJsonDataParsed manifest metadata.
options{ stripScope?: boolean; } = {}stripScope (default true): strip a leading @scope/
from the name fallback.

Members

Members

inferCliName

Infer the CLI binary name from manifest data.

Resolution order:

  1. First key of bin object (e.g. {"mycli": "./dist/cli.js"}"mycli")
  2. Package name, scope stripped by default (e.g. "@scope/mycli""mycli"); pass { stripScope: false } to keep the full scoped name
  3. undefined if neither exists

Note: bin keys are never scoped, so stripScope only affects the name fallback (relevant for deno.json / jsr.json, which have no bin field).

ts
(pkg: PackageJsonData, options: { stripScope?: boolean; }): string | undefined;

Examples

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

inferCliName({ bin: { mycli: './dist/cli.js' } });        // 'mycli'
inferCliName({ name: '@scope/mycli' });                   // 'mycli'
inferCliName({ name: '@scope/mycli' }, { stripScope: false }); // '@scope/mycli'
inferCliName({ name: 'mycli' });                          // 'mycli'
inferCliName({});                                         // undefined

See Also

Released under the MIT License.