@bybrave/prompts2
v3.0.0
Published
Maintained fork of prompts — lightweight, beautiful and user-friendly interactive prompts
Downloads
155
Maintainers
Readme
@bybrave/prompts2
Maintained fork of prompts — lightweight, beautiful and user-friendly interactive prompts for the terminal.
Why this fork
The original prompts has not been released since 2021 while very real papercuts kept piling up. This fork is a drop-in replacement that fixes them:
| Change | Upstream issue |
|---|---|
| Ctrl+C terminates the process (re-raises SIGINT after restoring the terminal) instead of silently continuing with partial answers; opt out with exitOnCtrlC: false | #252 |
| Cancelling a prompt no longer hangs the process: tearing down readline from inside its own keypress event left stdin in a state that kept the event loop alive forever | #87 |
| Native ESM entry point: import prompts from '@bybrave/prompts2' works without interop warnings | #393 |
| Types wired into the exports map, so TypeScript resolves them under node16/bundler resolution | #388 |
| Modernized: Node ≥ 18, tests on node:test (zero test deps), CI on Node 18/20/22 | — |
Install
npm install @bybrave/prompts2Usage
const prompts = require('@bybrave/prompts2');
// or: import prompts from '@bybrave/prompts2';
const response = await prompts({
type: 'number',
name: 'value',
message: 'How old are you?',
validate: (value) => (value < 18 ? 'Nightclub is 18+ only' : true),
});
console.log(response.value);All 12 prompt types (text, password, invisible, number, confirm, list, toggle, select, multiselect, autocompleteMultiselect, autocomplete, date), chaining, dynamic prompts, onState/onRender, inject and override work exactly as documented in the original README — the API is unchanged.
Ctrl+C behaviour
Pressing Ctrl+C now cleans up the terminal (cursor restored, raw mode off) and re-raises SIGINT, so your process terminates — or your own SIGINT handler runs. This is what users expect from a CLI and what the upstream maintainer planned for the next major.
To keep the old soft-cancel behaviour (prompt aborts, program continues via onCancel) for a specific question:
const response = await prompts({
type: 'confirm',
name: 'ok',
message: 'Continue?',
exitOnCtrlC: false,
});Esc and Ctrl+D remain soft cancels in both modes.
Migrating from prompts
- const prompts = require('prompts');
+ const prompts = require('@bybrave/prompts2');Breaking changes vs prompts@2:
- Ctrl+C terminates the process by default (opt out per question with
exitOnCtrlC: false) - Node ≥ 18 required
- The legacy
dist/build for Node 6 was removed
Support
If this package saves you time, you can support maintenance:
Bitcoin (BTC): bc1q37557q5jpeaxqydzwvf3jgj7zhnfpn2td3q40q
Credits & license
MIT. Based on prompts by Terkel Gjervig.
