Skip to content

Commit 3d40389

Browse files
committed
feat: add includeBorder to all prompts
1 parent 69508f4 commit 3d40389

File tree

10 files changed

+526
-167
lines changed

10 files changed

+526
-167
lines changed

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["src"]
3+
"include": ["src", "test"]
44
}

packages/prompts/src/box.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export interface BoxOptions extends CommonOptions {
3535
titlePadding?: number;
3636
contentPadding?: number;
3737
rounded?: boolean;
38-
includePrefix?: boolean;
3938
formatBorder?: (text: string) => string;
4039
}
4140

@@ -68,7 +67,7 @@ export const box = (message = '', title = '', opts?: BoxOptions) => {
6867
const titlePadding = opts?.titlePadding ?? 1;
6968
const contentPadding = opts?.contentPadding ?? 2;
7069
const width = opts?.width === undefined || opts.width === 'auto' ? 1 : Math.min(1, opts.width);
71-
const linePrefix = opts?.includePrefix ? `${S_BAR} ` : '';
70+
const linePrefix = opts?.withBorder === false ? '' : `${S_BAR} `;
7271
const formatBorder = opts?.formatBorder ?? defaultFormatBorder;
7372
const symbols = (opts?.rounded ? roundedSymbols : squareSymbols).map(formatBorder);
7473
const hSymbol = formatBorder(S_BAR_H);

packages/prompts/src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ export interface CommonOptions {
5757
input?: Readable;
5858
output?: Writable;
5959
signal?: AbortSignal;
60+
withBorder?: boolean;
6061
}

packages/prompts/src/log.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,32 @@ export const log = {
2323
secondarySymbol = color.gray(S_BAR),
2424
output = process.stdout,
2525
spacing = 1,
26+
withBorder,
2627
}: LogMessageOptions = {}
2728
) => {
2829
const parts: string[] = [];
30+
const isStandalone = withBorder === false;
31+
const spacingString = isStandalone ? '' : secondarySymbol;
32+
const prefix = isStandalone ? '' : `${symbol} `;
33+
const secondaryPrefix = isStandalone ? '' : `${secondarySymbol} `;
34+
2935
for (let i = 0; i < spacing; i++) {
30-
parts.push(`${secondarySymbol}`);
36+
parts.push(spacingString);
3137
}
38+
3239
const messageParts = Array.isArray(message) ? message : message.split('\n');
3340
if (messageParts.length > 0) {
3441
const [firstLine, ...lines] = messageParts;
3542
if (firstLine.length > 0) {
36-
parts.push(`${symbol} ${firstLine}`);
43+
parts.push(`${prefix}${firstLine}`);
3744
} else {
38-
parts.push(symbol);
45+
parts.push(isStandalone ? '' : symbol);
3946
}
4047
for (const ln of lines) {
4148
if (ln.length > 0) {
42-
parts.push(`${secondarySymbol} ${ln}`);
49+
parts.push(`${secondaryPrefix}${ln}`);
4350
} else {
44-
parts.push(secondarySymbol);
51+
parts.push(isStandalone ? '' : secondarySymbol);
4552
}
4653
}
4754
}

0 commit comments

Comments
 (0)