Skip to content

Commit 3fbca73

Browse files
authored
fix(utilities/cli): use chalk-template to render help message (vercel#713)
1 parent 995247d commit 3fbca73

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"arg": "5.0.2",
3939
"boxen": "7.0.0",
4040
"chalk": "5.0.1",
41+
"chalk-template": "0.4.0",
4142
"clipboardy": "3.0.0",
4243
"compression": "1.7.4",
4344
"is-port-reachable": "4.0.0",

pnpm-lock.yaml

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/main.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ const printUpdateNotification = async (debugMode?: boolean) => {
2828
const [error, update] = await resolve(checkForUpdate(manifest));
2929

3030
if (error) {
31-
const suffix = debugMode ? ':' : ' (use `--debug` to see full error)';
31+
const suffix = debugMode ? ':' : ' (use `--debug` to see full error).';
3232
logger.warn(`Checking for updates failed${suffix}`);
3333

3434
if (debugMode) logger.error(error.message);
3535
}
3636
if (!update) return;
3737

3838
logger.log(
39-
chalk` {bgRed.white UPDATE } The latest version of \`serve\` is ${update.latest}`,
39+
chalk.bgRed.white(' UPDATE '),
40+
`The latest version of \`serve\` is ${update.latest}.`,
4041
);
4142
};
4243

@@ -115,7 +116,7 @@ for (const endpoint of args['--listen']) {
115116
// If we are not in a TTY or Node is running in production mode, print
116117
// a single line of text with the server address.
117118
if (!process.stdout.isTTY || process.env.NODE_ENV === 'production') {
118-
const suffix = local ? ` at ${local}` : '';
119+
const suffix = local ? ` at ${local}.` : '.';
119120
logger.info(`Accepting connections${suffix}`);
120121
121122
continue;
@@ -144,7 +145,9 @@ for (const endpoint of args['--listen']) {
144145
await clipboard.write(local);
145146
message += `\n\n${chalk.grey('Copied local address to clipboard!')}`;
146147
} catch (error: unknown) {
147-
logger.error(`Cannot copy to clipboard: ${(error as Error).message}`);
148+
logger.error(
149+
`Cannot copy server address to clipboard: ${(error as Error).message}.`,
150+
);
148151
}
149152
}
150153

source/utilities/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// source/utilities/cli.ts
22
// CLI-related utility functions.
33

4-
import chalk from 'chalk';
4+
import chalk from 'chalk-template';
55
import parseArgv from 'arg';
66
import { parseEndpoint } from './http.js';
77
import type { Arguments } from '../types.js';

0 commit comments

Comments
 (0)