Skip to content

Commit

Permalink
fix: extra whitespace after update notifier (#1407)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Tatomyr <[email protected]>
  • Loading branch information
lornajane and tatomyr authored Feb 1, 2024
1 parent e61eb26 commit 7832121
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions packages/cli/src/utils/update-version-notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ const renderUpdateBanner = (current: string, latest: string) => {
const maxLength = Math.max(...messageLines.map((line) => cleanColors(line).length));

const border = yellow('═'.repeat(maxLength + SPACE_TO_BORDER));

const banner = `
${yellow('╔' + border + '╗')}
${yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
${messageLines
.map((line, index) => {
return getLineWithPadding(maxLength, line, index);
})
.join('\n')}
${yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║')}
${yellow('╚' + border + '╝')}
`;

const extraSpaces = ' '.repeat(SPACE_TO_BORDER);

const banner = [
'',
extraSpaces + yellow('╔' + border + '╗'),
extraSpaces + yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║'),
messageLines.map(getLineWithPadding(maxLength, extraSpaces)).join('\n'),
extraSpaces + yellow('║' + ' '.repeat(maxLength + SPACE_TO_BORDER) + '║'),
extraSpaces + yellow('╚' + border + '╝'),
'',
'',
].join('\n');
process.stderr.write(banner);
};

const getLineWithPadding = (maxLength: number, line: string, index: number): string => {
const padding = ' '.repeat(maxLength - cleanColors(line).length);
const extraSpaces = index !== 0 ? ' '.repeat(SPACE_TO_BORDER) : '';
return `${extraSpaces}${yellow('║')} ${line}${padding} ${yellow('║')}`;
};
const getLineWithPadding =
(maxLength: number, extraSpaces: string) =>
(line: string): string => {
const padding = ' '.repeat(maxLength - cleanColors(line).length);
return `${extraSpaces}${yellow('║')} ${line}${padding} ${yellow('║')}`;
};

const isNeedToBeCached = (): boolean => {
try {
Expand Down

1 comment on commit 7832121

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 76.1% 4306/5658
🟡 Branches 65.82% 2240/3403
🟡 Functions 68.74% 695/1011
🟡 Lines 76.31% 4049/5306

Test suite run success

699 tests passing in 100 suites.

Report generated by 🧪jest coverage report action from 7832121

Please sign in to comment.