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. gitformint guard scan --staged,--history,env,install-hookanduninstall-hook.
mint is ESM-only and has no runtime dependencies.
Global install#
npm install -g @xnah/mintThen:
mint --version
mint uuidWithout installing#
npx @xnah/mint uuid
npx @xnah/mint guard scanOther package managers#
pnpm add -g @xnah/mint
bun add -g @xnah/mintThe 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 --helpTo use the built binary as mint, link it:
npm link
mint uuidPackage 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/mintProgrammatic 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 6require('@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-copyorxsel
If none is available, mint prints a warning to stderr and still writes the value to stdout. It does not fail the command.
Troubleshooting#
| Symptom | Fix |
|---|---|
mint: unknown command | Run 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 warning | Install a clipboard helper, or pipe stdout into your secret manager. |
| Hook is skipped | The 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 installed | An existing hook is never replaced without --force. |