@astrojs/cli-kit
Advanced tools
Comparing version 0.2.3 to 0.2.4
/// <reference types="node" /> | ||
export declare const say: (messages?: string | string[], { clear, hat, stdin, stdout }?: { | ||
declare type Message = string | Promise<string>; | ||
export declare const say: (msg?: Message | Message[], { clear, hat, stdin, stdout }?: { | ||
clear?: boolean | undefined; | ||
@@ -13,1 +14,2 @@ hat?: string | undefined; | ||
export declare const label: (text: string, c?: import("chalk").ChalkInstance, t?: import("chalk").ChalkInstance) => string; | ||
export {}; |
@@ -6,4 +6,5 @@ import readline from 'node:readline'; | ||
import { action } from '../prompt/util/action.js'; | ||
import { strip } from '../prompt/util/clear.js'; | ||
export const say = async (messages = [], { clear = false, hat = '', stdin = process.stdin, stdout = process.stdout } = {}) => { | ||
import { strip, wrap } from '../prompt/util/clear.js'; | ||
export const say = async (msg = [], { clear = false, hat = '', stdin = process.stdin, stdout = process.stdout } = {}) => { | ||
const messages = Array.isArray(msg) ? msg : [msg]; | ||
const rl = readline.createInterface({ input: stdin, escapeCodeTimeout: 50 }); | ||
@@ -44,3 +45,2 @@ const logUpdate = createLogUpdate(stdout, { showCursor: false }); | ||
}); | ||
const _messages = Array.isArray(messages) ? messages : [messages]; | ||
const eyes = useAscii() ? ['•', '•', 'o', 'o', '•', 'O', '^', '•'] : ['●', '●', '●', '●', '●', '○', '○', '•']; | ||
@@ -54,9 +54,13 @@ const mouths = useAscii() ? ['•', 'O', '*', 'o', 'o', '•', '-'] : ['•', '○', '■', '▪', '▫', '▬', '▭', '-', '○']; | ||
const head = h.repeat(3 - strip(hat).split('').length); | ||
const prefix = ' '.repeat(9); | ||
const [message, secondMessage = '', ...lines] = wrap(`${prefix}${msg}`, prefix).split('\n'); | ||
return [ | ||
`${tl}${h.repeat(2)}${hat}${head}${tr} ${color.bold(color.cyan('Houston:'))}`, | ||
`${v} ${eye} ${color.cyanBright(mouth)} ${eye} ${msg}`, | ||
`${bl}${h.repeat(5)}${br}`, | ||
`${v} ${eye} ${color.cyanBright(mouth)} ${eye} ${message.trimStart()}`, | ||
`${bl}${h.repeat(5)}${br} ${secondMessage.trimStart()}`, | ||
...lines | ||
].join('\n'); | ||
}; | ||
for (const message of _messages) { | ||
for (let message of messages) { | ||
message = await message; | ||
const _message = Array.isArray(message) ? message : message.split(' '); | ||
@@ -63,0 +67,0 @@ let msg = []; |
@@ -21,2 +21,6 @@ export const action = (key, isSelect) => { | ||
return 'up'; | ||
if (key.ctrl && key.name === 'n') | ||
return 'down'; | ||
if (key.ctrl && key.name === 'p') | ||
return 'up'; | ||
} | ||
@@ -23,0 +27,0 @@ if (key.name === 'return') |
@@ -30,3 +30,3 @@ import { erase, cursor } from "sisteransi"; | ||
if (i + len > max) { | ||
i = 0; | ||
i = indent.length; | ||
lines.push('\n' + indent, raw); | ||
@@ -33,0 +33,0 @@ } |
{ | ||
"name": "@astrojs/cli-kit", | ||
"type": "module", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53881
1669