Clean up helpers which are always present in ES2020 (#55515)

This commit is contained in:
Jake Bailey
2023-08-28 12:26:22 -07:00
committed by GitHub
parent 5ce34cafad
commit b5b6048bb3
13 changed files with 37 additions and 199 deletions

View File

@@ -61,8 +61,6 @@ import {
optionDeclarations,
optionsForBuild,
optionsForWatch,
padLeft,
padRight,
parseBuildCommand,
parseCommandLine,
parseConfigFileWithSystem,
@@ -329,12 +327,12 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
while (remainRight.length > 0) {
let curLeft = "";
if (isFirstLine) {
curLeft = padLeft(left, rightAlignOfLeft);
curLeft = padRight(curLeft, leftAlignOfRight);
curLeft = left.padStart(rightAlignOfLeft);
curLeft = curLeft.padEnd(leftAlignOfRight);
curLeft = colorLeft ? colors.blue(curLeft) : curLeft;
}
else {
curLeft = padLeft("", leftAlignOfRight);
curLeft = "".padStart(leftAlignOfRight);
}
const curRight = remainRight.substr(0, rightCharacterNumber);
@@ -524,15 +522,15 @@ function getHeader(sys: System, message: string) {
const terminalWidth = sys.getWidthOfTerminal?.() ?? 0;
const tsIconLength = 5;
const tsIconFirstLine = colors.blueBackground(padLeft("", tsIconLength));
const tsIconSecondLine = colors.blueBackground(colors.brightWhite(padLeft("TS ", tsIconLength)));
const tsIconFirstLine = colors.blueBackground("".padStart(tsIconLength));
const tsIconSecondLine = colors.blueBackground(colors.brightWhite("TS ".padStart(tsIconLength)));
// If we have enough space, print TS icon.
if (terminalWidth >= message.length + tsIconLength) {
// right align of the icon is 120 at most.
const rightAlign = terminalWidth > 120 ? 120 : terminalWidth;
const leftAlign = rightAlign - tsIconLength;
header.push(padRight(message, leftAlign) + tsIconFirstLine + sys.newLine);
header.push(padLeft("", leftAlign) + tsIconSecondLine + sys.newLine);
header.push(message.padEnd(leftAlign) + tsIconFirstLine + sys.newLine);
header.push("".padStart(leftAlign) + tsIconSecondLine + sys.newLine);
}
else {
header.push(message + sys.newLine);
@@ -1261,7 +1259,7 @@ function reportAllStatistics(sys: System, statistics: Statistic[]) {
}
for (const s of statistics) {
sys.write(padRight(s.name + ":", nameSize + 2) + padLeft(statisticValue(s).toString(), valueSize) + sys.newLine);
sys.write(`${s.name}:`.padEnd(nameSize + 2) + statisticValue(s).toString().padStart(valueSize) + sys.newLine);
}
}