github-actions
released this
19 Dec 20:28
·
5 commits
to main
since this release
Minor Changes
-
a83d2f8: Adds a new
updateSettings()
function to support new global keybindings.updateSettings()
accepts analiases
object that maps custom keys to an action (up | down | left | right | space | enter | cancel
).import { updateSettings } from "@clack/prompts"; // Support custom keybindings updateSettings({ aliases: { w: "up", a: "left", s: "down", d: "right", }, });
Warning
In order to enforce consistent, user-friendly defaults across the ecosystem, updateSettings
does not support disabling Clack's default keybindings.
-
801246b: Adds a new
signal
option to support programmatic prompt cancellation with an abort controller.One example use case is automatically cancelling a prompt after a timeout.
const shouldContinue = await confirm({ message: "This message will self destruct in 5 seconds", signal: AbortSignal.timeout(5000), });
Another use case is racing a long running task with a manual prompt.
const abortController = new AbortController(); const projectType = await Promise.race([ detectProjectType({ signal: abortController.signal, }), select({ message: "Pick a project type.", options: [ { value: "ts", label: "TypeScript" }, { value: "js", label: "JavaScript" }, { value: "coffee", label: "CoffeeScript", hint: "oh no" }, ], signal: abortController.signal, }), ]); abortController.abort();
-
a83d2f8: Updates default keybindings to support Vim motion shortcuts and map the
escape
key to cancel (ctrl+c
).alias action k
up l
right j
down h
left esc
cancel