mint_
Documentation menu
On this page

Start / Documentation

Installation

npm, npx, pnpm, bun, source installs and programmatic use.

Requirements#

  • Node.js 18 or newer.
  • A POSIX-like shell for the pre-commit hook. On Windows, use Git Bash or WSL for mint guard install-hook.
  • git for mint guard scan --staged, --history, env, install-hook and uninstall-hook.

mint is ESM-only and has no runtime dependencies.

Global install#

npm install -g @xnah/mint

Then:

mint --version
mint uuid

Without installing#

npx @xnah/mint uuid
npx @xnah/mint guard scan

Other package managers#

pnpm add -g @xnah/mint
bun add -g @xnah/mint

The binary name is always mint, regardless of the package manager.

From source#

git clone https://github.com/h4nxxlmao/mint
cd mint
npm install
npm run build
node dist/cli.js --help

To use the built binary as mint, link it:

npm link
mint uuid

Package rename#

The package is published as @xnah/mint. The older name @npm-install-hanx/mint is deprecated and points at the same package. If you have the old name installed, replace it:

npm uninstall -g @npm-install-hanx/mint
npm install -g @xnah/mint

Programmatic use#

import { mint, mintValue, sampleChars, randomIntBelow } from '@xnah/mint';

mint('uuid');
// { value: '...', entropyBits: 122, fields: { version: 4 } }

mintValue('hex', { bytes: 32 });
// 64 lowercase hex characters

mintValue('pick', {}, ['red', 'green']);
// one of the two strings

sampleChars(12, 'abc');
// 12 characters, uniformly sampled

randomIntBelow(6) + 1;
// a uniform integer from 1 to 6

require('@xnah/mint') works on Node 22.12 and newer where require(esm) is supported. On Node 18 and 20, use await import('@xnah/mint').

Clipboard helpers#

--copy shells out to a platform helper:

  • macOS: pbcopy
  • Windows: clip
  • Linux: xclip, wl-copy or xsel

If none is available, mint prints a warning to stderr and still writes the value to stdout. It does not fail the command.

Troubleshooting#

SymptomFix
mint: unknown commandRun mint --help; the command may have a different name.
is not supported by "mint ..."Run mint <command> --help to see the flags that command accepts.
Clipboard warningInstall a clipboard helper, or pipe stdout into your secret manager.
Hook is skippedThe hook warns when mint is not on PATH and lets the commit through. Install mint or add ./node_modules/.bin to PATH.
Hook was not installedAn existing hook is never replaced without --force.