-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix: allow multiple bindCLIShortcuts calls with shortcut merging
#21103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: 翠 <green@sapphi.red>
sapphi-red
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
ArnaudBarre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks!
| await vi.waitFor(() => expect(xUpdatedAction).toHaveBeenCalledOnce()) | ||
|
|
||
| // Ensure original xAction is not called again | ||
| expect(xAction).not.toBeCalled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a miss-understanding of the mocking system but I don't understand this assertion. Does using toHaveBeenCalledOnce above "reset" the counter? Otherwise I would have use toHaveBeenCalledOnce again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reset the counter with xAction.mockClear() right before calling bindCLIShortcuts again. If you find it confusing, happy to remove that and just assert whether xAction is still only called once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I missed that line. Ok makes more sense thanks. I think it just taste then so no need to change
|
Thanks for the review, @sapphi-red and @ArnaudBarre 🙌🏼 |
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.2.2 | 7.2.4 | ## [v7.2.4](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-724-2025-11-20-small) ##### Bug Fixes - revert "perf(deps): replace debug with obug ([#21107](vitejs/vite#21107))" ([2d66b7b](vitejs/vite@2d66b7b)) ## [v7.2.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-723-2025-11-20-small) ##### Bug Fixes - allow multiple `bindCLIShortcuts` calls with shortcut merging ([#21103](vitejs/vite#21103)) ([5909efd](vitejs/vite@5909efd)) - **deps:** update all non-major dependencies ([#21096](vitejs/vite#21096)) ([6a34ac3](vitejs/vite@6a34ac3)) - **deps:** update all non-major dependencies ([#21128](vitejs/vite#21128)) ([4f8171e](vitejs/vite@4f8171e)) ##### Performance Improvements - **deps:** replace debug with obug ([#21107](vitejs/vite#21107)) ([acfe939](vitejs/vite@acfe939)) ##### Miscellaneous Chores - **deps:** update dependency [@rollup/plugin-commonjs](https://github.com/rollup/plugin-commonjs) to v29 ([#21099](vitejs/vite#21099)) ([02ceaec](vitejs/vite@02ceaec)) - **deps:** update rolldown-related dependencies ([#21095](vitejs/vite#21095)) ([39a0a15](vitejs/vite@39a0a15)) - **deps:** update rolldown-related dependencies ([#21127](vitejs/vite#21127)) ([5029720](vitejs/vite@5029720))
Fixes #15781.
Closes #15881.
This fixes an issue where calling
bindCLIShortcuts()multiple times would create duplicate readline instances and lose custom shortcuts from previous calls. This is useful for plugins adding their own shortcuts while Vite CLI continues to print the help message.Now when you bind shortcuts multiple times, they are properly merged, with new custom shortcuts taking priority:
This works for both dev and preview server.