File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ extern crate mdbook;
4
4
extern crate tempdir;
5
5
6
6
use std:: fs:: File ;
7
+ use std:: path:: Path ;
7
8
use tempdir:: TempDir ;
8
9
use mdbook:: config:: Config ;
9
10
use mdbook:: MDBook ;
@@ -30,11 +31,22 @@ fn alternate_backend_with_arguments() {
30
31
md. build ( ) . unwrap ( ) ;
31
32
}
32
33
34
+ /// Get a command which will pipe `stdin` to the provided file.
35
+ fn tee_command < P : AsRef < Path > > ( out_file : P ) -> String {
36
+ let out_file = out_file. as_ref ( ) ;
37
+
38
+ if cfg ! ( windows) {
39
+ format ! ( "cmd.exe /c type ^> \" {}\" " , out_file. display( ) )
40
+ } else {
41
+ format ! ( "tee {}" , out_file. display( ) )
42
+ }
43
+ }
44
+
33
45
#[ test]
34
46
fn backends_receive_render_context_via_stdin ( ) {
35
47
let temp = TempDir :: new ( "output" ) . unwrap ( ) ;
36
48
let out_file = temp. path ( ) . join ( "out.txt" ) ;
37
- let cmd = format ! ( "tee {}" , out_file. display ( ) ) ;
49
+ let cmd = tee_command ( & out_file) ;
38
50
39
51
let ( md, _temp) = dummy_book_with_backend ( "cat-to-file" , & cmd) ;
40
52
You can’t perform that action at this time.
0 commit comments