File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,15 @@ export type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
1414 /**
1515 * Custom shortcuts to run when a key is pressed. These shortcuts take priority
1616 * over the default shortcuts if they have the same keys (except the `h` key).
17+ * To disable a default shortcut, define the same key but with `action: undefined`.
1718 */
1819 customShortcuts ?: CLIShortcut < Server > [ ]
1920}
2021
2122export type CLIShortcut < Server = ViteDevServer | PreviewServer > = {
2223 key : string
2324 description : string
24- action ( server : Server ) : void | Promise < void >
25+ action ? ( server : Server ) : void | Promise < void >
2526}
2627
2728export function bindCLIShortcuts < Server extends ViteDevServer | PreviewServer > (
@@ -66,6 +67,8 @@ export function bindCLIShortcuts<Server extends ViteDevServer | PreviewServer>(
6667 if ( loggedKeys . has ( shortcut . key ) ) continue
6768 loggedKeys . add ( shortcut . key )
6869
70+ if ( shortcut . action == null ) continue
71+
6972 server . config . logger . info (
7073 colors . dim ( ' press ' ) +
7174 colors . bold ( `${ shortcut . key } + enter` ) +
@@ -77,7 +80,7 @@ export function bindCLIShortcuts<Server extends ViteDevServer | PreviewServer>(
7780 }
7881
7982 const shortcut = shortcuts . find ( ( shortcut ) => shortcut . key === input )
80- if ( ! shortcut ) return
83+ if ( ! shortcut || shortcut . action == null ) return
8184
8285 actionRunning = true
8386 await shortcut . action ( server )
You can’t perform that action at this time.
0 commit comments