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 22
22
use anyhow:: { Ok , Result , anyhow} ;
23
23
use clap:: { Parser , Subcommand } ;
24
24
use std:: path:: { Path , PathBuf } ;
25
+ use std:: process:: Stdio ;
25
26
use std:: { env, process:: Command } ;
26
27
27
28
fn main ( ) -> Result < ( ) > {
@@ -128,9 +129,35 @@ fn install_tools() -> Result<()> {
128
129
}
129
130
}
130
131
132
+ // Uninstall original linkcheck if currently installed (see issue no 2773)
133
+ uninstall_mdbook_linkcheck ( ) ;
134
+
131
135
Ok ( ( ) )
132
136
}
133
137
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
+
134
161
fn run_web_tests ( dir : Option < PathBuf > ) -> Result < ( ) > {
135
162
println ! ( "Running web tests..." ) ;
136
163
You can’t perform that action at this time.
0 commit comments