fix(cli): suppress VITE+ header for lint/fmt LSP and stdin flows#1619
Draft
fengmk2 wants to merge 1 commit into
Draft
fix(cli): suppress VITE+ header for lint/fmt LSP and stdin flows#1619fengmk2 wants to merge 1 commit into
fengmk2 wants to merge 1 commit into
Conversation
The cosmetic "VITE+ - The Unified Toolchain for the Web" banner is printed before delegating to oxlint/oxfmt, which corrupts the stdout stream that IDE extensions parse as LSP protocol or formatted source. Skip the banner for: - `vp lint --lsp` - `vp fmt --lsp` - `vp fmt --stdin-filepath` (also `--stdin-filepath=<path>`) All other invocations of `vp lint` / `vp fmt` remain subject to the existing TTY / `GIT_INDEX_FILE` suppressions in `vite_shared::header::should_print_header()`. Refs #1557
✅ Deploy Preview for viteplus-preview canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The cosmetic
VITE+ - The Unified Toolchain for the Webbanner is printed to stdout beforevp lint/vp fmtdelegate 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 --lspvp fmt --lspvp fmt --stdin-filepath(also--stdin-filepath=<path>)All other invocations of
vp lint/vp fmtare unchanged and remain subject to the existing TTY /GIT_INDEX_FILEsuppressions invite_shared::header::should_print_header().Implementation lives in
crates/vite_global_cli/src/cli.rs:should_suppress_header_for_subcommand("lint"|"fmt", &args)predicate, mirroring the existingshould_force_global_delegateshape and reusinghas_flag_before_terminator(so--lsp=...,--stdin-filepath=..., and the--option terminator are all handled correctly).maybe_print_runtime_header(command, args, show_header)wrapper aroundprint_runtime_header, used at the two call sites.Refs #1557 (first checkbox; the bin-wrapper deprecation and editor-extension updates remain).
Test plan
cargo test -p vite_global_cli suppresses_header— 2 positive tests passcargo test -p vite_global_cli does_not_suppress— 4 negative tests pass (incl.--option terminator, unknown subcommand, fmt--check)cargo fmt -p vite_global_cli -- --checkcleancargo clippy -p vite_global_cli --testscleanvp lint→ banner printedvp lint --lsp→ no banner; stdout is pure LSP protocolvp fmt→ banner printedvp fmt --lsp→ no bannerecho 'const a=1' | vp fmt --stdin-filepath foo.ts→ no banner; stdout is just formatted sourceecho 'const a=1' | vp fmt --stdin-filepath=foo.ts→ samevp check(composite) → unaffected