Skip to content

Commit

Permalink
fix: improve CLI shortcuts help display (#11247)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Dec 7, 2022
1 parent 4efb188 commit bb235b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ export function printServerUrls(
info(` ${colors.green('➜')} ${colors.bold('Network')}: ${colorUrl(url)}`)
}
if (urls.network.length === 0 && optionsHost === undefined) {
const note = `use ${colors.reset(colors.bold('--host'))} to expose`
info(
colors.dim(` ${colors.green('➜')} ${colors.bold('Network')}: ${note}`),
colors.dim(` ${colors.green('➜')} ${colors.bold('Network')}: use `) +
colors.bold('--host') +
colors.dim(' to expose'),
)
}
}
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export interface ViteDevServer {
* @internal
* Actually BindShortcutsOptions | undefined but api-extractor checks for
* export before trimming internal types :(
* And I don't want to complexity prePatchTypes for that
* And I don't want to add complexity to prePatchTypes for that
*/
_shortcutsOptions: any | undefined
}
Expand Down
10 changes: 6 additions & 4 deletions packages/vite/src/node/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ export function bindShortcuts(

if (input === 'h') {
server.config.logger.info(
shortcuts
.map(
[
'',
colors.bold(' Shortcuts'),
...shortcuts.map(
(shortcut) =>
colors.dim(' press ') +
colors.bold(shortcut.key) +
colors.dim(` to ${shortcut.description}`),
)
.join('\n'),
),
].join('\n'),
)
}

Expand Down

0 comments on commit bb235b2

Please sign in to comment.