Commit 65f850b
authored
fix(cli): suppress VITE+ header for lint/fmt LSP and stdin flows (#1619)
## Summary
The cosmetic `VITE+ - The Unified Toolchain for the Web` banner is
printed to stdout before `vp lint` / `vp fmt` delegate to oxlint/oxfmt.
For IDE-launched subprocesses (`--lsp`, `--stdin-filepath`) the editor
parses stdout as the LSP protocol or as formatted source, so the banner
corrupts the stream.
Skip the banner exactly when:
- `vp lint --lsp`
- `vp fmt --lsp`
- `vp fmt --stdin-filepath` (also `--stdin-filepath=<path>`)
All other invocations of `vp lint` / `vp fmt` are unchanged and remain
subject to the existing TTY / `GIT_INDEX_FILE` suppressions in
`vite_shared::header::should_print_header()`.
Implementation lives in `crates/vite_global_cli/src/cli.rs`:
- New `should_suppress_header_for_subcommand("lint"|"fmt", &args)`
predicate, mirroring the existing `should_force_global_delegate` shape
and reusing `has_flag_before_terminator` (so `--lsp=...`,
`--stdin-filepath=...`, and the `--` option terminator are all handled
correctly).
- New `maybe_print_runtime_header(command, args, show_header)` wrapper
around `print_runtime_header`, used at the two call sites.
Refs #1557 (first checkbox; the bin-wrapper deprecation and
editor-extension updates remain).
## Test plan
- [x] `cargo test -p vite_global_cli suppresses_header` — 2 positive
tests pass
- [x] `cargo test -p vite_global_cli does_not_suppress` — 4 negative
tests pass (incl. `--` option terminator, unknown subcommand, fmt
`--check`)
- [x] `cargo fmt -p vite_global_cli -- --check` clean
- [x] `cargo clippy -p vite_global_cli --tests` clean
- [ ] Manual smoke (in a Vite+ project, attached TTY):
- [ ] `vp lint` → banner printed
- [ ] `vp lint --lsp` → no banner; stdout is pure LSP protocol
- [ ] `vp fmt` → banner printed
- [ ] `vp fmt --lsp` → no banner
- [ ] `echo 'const a=1' | vp fmt --stdin-filepath foo.ts` → no banner;
stdout is just formatted source
- [ ] `echo 'const a=1' | vp fmt --stdin-filepath=foo.ts` → same
- [ ] `vp check` (composite) → unaffected1 parent 4d8ba95 commit 65f850b
1 file changed
Lines changed: 75 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
471 | 487 | | |
472 | 488 | | |
473 | 489 | | |
| |||
777 | 793 | | |
778 | 794 | | |
779 | 795 | | |
780 | | - | |
| 796 | + | |
781 | 797 | | |
782 | 798 | | |
783 | 799 | | |
| |||
789 | 805 | | |
790 | 806 | | |
791 | 807 | | |
792 | | - | |
| 808 | + | |
793 | 809 | | |
794 | 810 | | |
795 | 811 | | |
| |||
886 | 902 | | |
887 | 903 | | |
888 | 904 | | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
889 | 912 | | |
890 | 913 | | |
891 | 914 | | |
| |||
933 | 956 | | |
934 | 957 | | |
935 | 958 | | |
| 959 | + | |
936 | 960 | | |
937 | 961 | | |
938 | 962 | | |
| |||
981 | 1005 | | |
982 | 1006 | | |
983 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
984 | 1057 | | |
0 commit comments