Skip to content

Main content

Package JSON Bin Shorthand Normalizer

Normalize an explicit package bin shorthand into an unscoped command name and unchanged executable path.

Loading tool…

Description

Extract a command name and path from restricted package-name shorthand.

Development metadata distinguishes source-map deltas, package-person formatting, executable shorthand and Git object modes. A string with package-like syntax need not satisfy the complete registry or package contract. Formatting a person, extracting a command name or mapping a mode does not inspect files or modify a repository.

Extract a command name and path from restricted package-name shorthand.

When to use this tool

Use Package JSON Bin Shorthand Normalizer when you already have packageName, binPath and need to extract a command name and path from restricted package-name shorthand.

How to use the tool and how it works

  1. Enter packageName, binPath. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read commandName, binPath. Use the output convention below.

Require a lowercase ASCII alphanumeric-leading name with allowed letters/digits/dot/underscore/hyphen, optionally @scope/name, and nonempty binPath. Command is the unscoped final name; preserve the path.1

A single executable can use bin shorthand associated with the package name. Extracting a command and path does not install that executable or validate the full package contract.2

Input fieldMeaning and unitsAccepted input
packageNamePackage NameRequired. Text; maximum UTF-16 length 8192.
binPathBin PathRequired. Text; minimum UTF-16 length 1; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
commandNameUnscoped package-name component under the restricted grammar; no executable is created.Required. Text; maximum UTF-16 length 8192.
binPathBin PathRequired. Text; maximum UTF-16 length 8192.
json
{
  "input": {
    "packageName": "@scope/cli-tool",
    "binPath": "./cli.js"
  },
  "output": {
    "commandName": "cli-tool",
    "binPath": "./cli.js"
  }
}

Limitations and assumptions

  • The grammar is not full npm package-name validation. No path, executable, file, bin object, installation or command collision is checked.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Validate the full source map, package metadata or Git object when conformance matters. Use the relevant complete format and actual file/object information; a local delta or grammar check does not establish a valid package, executable, source mapping or tree entry.

References

  1. Calculation and input contract: development/package-json-bin-shorthand-normalizer — tool.io

  2. npm package.json: Executable shorthand — npm

Similar or alternative tools