File tree Expand file tree Collapse file tree
snap-tests-global/command-run-script-vite-program Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -551,14 +551,19 @@ impl CommandHandler for VitePlusCommandHandler {
551551 & mut self ,
552552 command : & mut ScriptCommand ,
553553 ) -> anyhow:: Result < HandledCommand > {
554- // Intercept "vp" commands in task scripts so that `vp test`, `vp build`, etc.
555- // are synthesized in-session rather than spawning a new CLI process.
554+ // Intercept "vp" and "vpr" commands in task scripts so that `vp test`, `vp build`,
555+ // `vpr build`, etc. are synthesized in-session rather than spawning a new CLI process.
556556 let program = command. program . as_str ( ) ;
557- if program != "vp" {
557+ if program != "vp" && program != "vpr" {
558558 return Ok ( HandledCommand :: Verbatim ) ;
559559 }
560+ // "vpr <args>" is shorthand for "vp run <args>", so prepend "run" for parsing.
560561 let cli_args = match CLIArgs :: try_parse_from (
561- iter:: once ( "vp" ) . chain ( command. args . iter ( ) . map ( Str :: as_str) ) ,
562+ iter:: once ( "vp" ) . chain (
563+ if program == "vpr" { Some ( "run" ) } else { None }
564+ . into_iter ( )
565+ . chain ( command. args . iter ( ) . map ( Str :: as_str) ) ,
566+ ) ,
562567 ) {
563568 Ok ( args) => args,
564569 Err ( err) if err. kind ( ) == ErrorKind :: InvalidSubcommand => {
Original file line number Diff line number Diff line change 44 "scripts" : {
55 "dev" : " vite" ,
66 "dev-help" : " vite -h" ,
7- "dev-version" : " vite --version"
7+ "dev-version" : " vite --version" ,
8+ "hello" : " echo hello from script" ,
9+ "hello-vpr" : " vpr hello" ,
10+ "ready" : " vpr hello-vpr && vpr dev-version"
811 },
912 "packageManager" : " pnpm@10.19.0"
1013}
Original file line number Diff line number Diff line change @@ -19,3 +19,22 @@ VITE+ - The Unified Toolchain for the Web
1919$ vite --version ⊘ cache disabled
2020vite --version
2121
22+
23+ > vp run hello-vpr # vpr in script should be synthesized in-session
24+ VITE+ - The Unified Toolchain for the Web
25+
26+ $ echo hello from script ⊘ cache disabled
27+ hello from script
28+
29+
30+ > vp run ready # chained vpr commands should both be synthesized
31+ VITE+ - The Unified Toolchain for the Web
32+
33+ $ echo hello from script ⊘ cache disabled
34+ hello from script
35+
36+ $ vite --version ⊘ cache disabled
37+ vite --version
38+
39+ ---
40+ vp run: 0/2 cache hit (0%). (Run `vp run --last-details` for full details)
Original file line number Diff line number Diff line change 33 { "command" : " node setup-bin.js" , "ignoreOutput" : true },
44 " vp run dev # should run vite binary, not parse as vp subcommand" ,
55 " vp run dev-help # should run vite -h, not parse as vp subcommand" ,
6- " vp run dev-version # should run vite --version, not parse as vp subcommand"
6+ " vp run dev-version # should run vite --version, not parse as vp subcommand" ,
7+ " vp run hello-vpr # vpr in script should be synthesized in-session" ,
8+ " vp run ready # chained vpr commands should both be synthesized"
79 ]
810}
You can’t perform that action at this time.
0 commit comments