Skip to content

inferCliName

Generated reference page for the inferCliName function export.

Signatures

ts
function inferCliName(pkg: PackageJsonData): string | undefined;

Members

Members

inferCliName

Infer the CLI binary name from package.json data.

Resolution order:

  1. First key of bin object (e.g. {"mycli": "./dist/cli.js"}"mycli")
  2. Package name with scope stripped (e.g. "@scope/mycli""mycli")
  3. undefined if neither exists
ts
(pkg: PackageJsonData): string | undefined;

Examples

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

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

See Also

Released under the MIT License.