File tree 1 file changed +5
-2
lines changed
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> = {
14
14
/**
15
15
* Custom shortcuts to run when a key is pressed. These shortcuts take priority
16
16
* 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`.
17
18
*/
18
19
customShortcuts ?: CLIShortcut < Server > [ ]
19
20
}
20
21
21
22
export type CLIShortcut < Server = ViteDevServer | PreviewServer > = {
22
23
key : string
23
24
description : string
24
- action ( server : Server ) : void | Promise < void >
25
+ action ? ( server : Server ) : void | Promise < void >
25
26
}
26
27
27
28
export function bindCLIShortcuts < Server extends ViteDevServer | PreviewServer > (
@@ -66,6 +67,8 @@ export function bindCLIShortcuts<Server extends ViteDevServer | PreviewServer>(
66
67
if ( loggedKeys . has ( shortcut . key ) ) continue
67
68
loggedKeys . add ( shortcut . key )
68
69
70
+ if ( shortcut . action == null ) continue
71
+
69
72
server . config . logger . info (
70
73
colors . dim ( ' press ' ) +
71
74
colors . bold ( `${ shortcut . key } + enter` ) +
@@ -77,7 +80,7 @@ export function bindCLIShortcuts<Server extends ViteDevServer | PreviewServer>(
77
80
}
78
81
79
82
const shortcut = shortcuts . find ( ( shortcut ) => shortcut . key === input )
80
- if ( ! shortcut ) return
83
+ if ( ! shortcut || shortcut . action == null ) return
81
84
82
85
actionRunning = true
83
86
await shortcut . action ( server )
You can’t perform that action at this time.
0 commit comments