[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

Replace custom ANSI regex logic with Node built-in (#224)

authored by

Nate Moore and committed by
GitHub
(Jan 4, 2025, 1:32 AM -0600) 1904e57d edd4425f

+6 -26
+5
.changeset/slimy-dolphins-press.md
··· 1 + --- 2 + "@clack/prompts": patch 3 + --- 4 + 5 + Replace custom utility for stripping ANSI control sequences with Node's built-in [`stripVTControlCharacters`](https://nodejs.org/docs/latest/api/util.html#utilstripvtcontrolcharactersstr) utility.
-14
packages/prompts/LICENSE
··· 7 7 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 8 9 9 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 - 11 - --- 12 - 13 - `ansi-regex` is adapted from https://github.com/chalk/ansi-regex 14 - 15 - MIT License 16 - 17 - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) 18 - 19 - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 20 - 21 - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 - 23 - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+1 -12
packages/prompts/src/index.ts
··· 1 + import { stripVTControlCharacters as strip } from 'node:util'; 1 2 import { 2 3 ConfirmPrompt, 3 4 GroupMultiSelectPrompt, ··· 569 570 }).prompt() as Promise<Value[] | symbol>; 570 571 }; 571 572 572 - const strip = (str: string) => str.replace(ansiRegex(), ''); 573 573 export const note = (message = '', title = '') => { 574 574 const lines = `\n${message}\n`.split('\n'); 575 575 const titleLen = strip(title).length; ··· 739 739 message, 740 740 }; 741 741 }; 742 - 743 - // Adapted from https://github.com/chalk/ansi-regex 744 - // @see LICENSE 745 - function ansiRegex() { 746 - const pattern = [ 747 - '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', 748 - '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))', 749 - ].join('|'); 750 - 751 - return new RegExp(pattern, 'g'); 752 - } 753 742 754 743 export type PromptGroupAwaitedReturn<T> = { 755 744 [P in keyof T]: Exclude<Awaited<T[P]>, symbol>;