File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 2222use anyhow:: { Ok , Result , anyhow} ;
2323use clap:: { Parser , Subcommand } ;
2424use std:: path:: { Path , PathBuf } ;
25+ use std:: process:: Stdio ;
2526use std:: { env, process:: Command } ;
2627
2728fn main ( ) -> Result < ( ) > {
@@ -128,9 +129,35 @@ fn install_tools() -> Result<()> {
128129 }
129130 }
130131
132+ // Uninstall original linkcheck if currently installed (see issue no 2773)
133+ uninstall_mdbook_linkcheck ( ) ;
134+
131135 Ok ( ( ) )
132136}
133137
138+ fn uninstall_mdbook_linkcheck ( ) {
139+ println ! ( "Uninstalling old mdbook-linkcheck if installed..." ) ;
140+ let output = Command :: new ( env ! ( "CARGO" ) )
141+ . arg ( "uninstall" )
142+ . arg ( "mdbook-linkcheck" )
143+ . output ( )
144+ . expect ( "Failed to execute cargo uninstall mdbook-linkcheck" ) ;
145+
146+ if !output. status . success ( ) {
147+ if String :: from_utf8_lossy ( & output. stderr )
148+ . into_owned ( )
149+ . contains ( "did not match any packages" )
150+ {
151+ println ! ( "mdbook-linkcheck not installed. Continuing..." ) ;
152+ } else {
153+ eprintln ! (
154+ "An error occurred during uninstallation of mdbook-linkcheck:\n {:#?}" ,
155+ String :: from_utf8_lossy( & output. stderr)
156+ ) ;
157+ }
158+ }
159+ }
160+
134161fn run_web_tests ( dir : Option < PathBuf > ) -> Result < ( ) > {
135162 println ! ( "Running web tests..." ) ;
136163
You can’t perform that action at this time.
0 commit comments