@@ -16,6 +16,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
16
16
use std:: borrow:: Cow ;
17
17
use std:: env;
18
18
use std:: mem;
19
+ use std:: path:: Path ;
19
20
use tracing:: { debug, instrument, warn} ;
20
21
21
22
#[ derive( Debug , Default , PartialEq ) ]
@@ -580,8 +581,8 @@ impl<'graph> TokenExpander<'graph> {
580
581
"arch" => Cow :: Borrowed ( env:: consts:: ARCH ) ,
581
582
"os" => Cow :: Borrowed ( env:: consts:: OS ) ,
582
583
"osFamily" => Cow :: Borrowed ( env:: consts:: FAMILY ) ,
583
- "workingDir" => Cow :: Owned ( path :: to_string ( & self . context . working_dir ) ?) ,
584
- "workspaceRoot" => Cow :: Owned ( path :: to_string ( & self . context . workspace_root ) ?) ,
584
+ "workingDir" => Cow :: Owned ( self . stringify_path ( & self . context . working_dir ) ?) ,
585
+ "workspaceRoot" => Cow :: Owned ( self . stringify_path ( & self . context . workspace_root ) ?) ,
585
586
// Project
586
587
"language" => Cow :: Owned ( project. language . to_string ( ) ) ,
587
588
"project" => Cow :: Borrowed ( project. id . as_str ( ) ) ,
@@ -592,7 +593,7 @@ impl<'graph> TokenExpander<'graph> {
592
593
"projectChannel" => get_metadata ( |md| md. channel . as_deref ( ) ) ,
593
594
"projectName" => get_metadata ( |md| md. name . as_deref ( ) ) ,
594
595
"projectOwner" => get_metadata ( |md| md. owner . as_deref ( ) ) ,
595
- "projectRoot" => Cow :: Owned ( path :: to_string ( & project. root ) ?) ,
596
+ "projectRoot" => Cow :: Owned ( self . stringify_path ( & project. root ) ?) ,
596
597
"projectSource" => Cow :: Borrowed ( project. source . as_str ( ) ) ,
597
598
"projectStack" => Cow :: Owned ( project. stack . to_string ( ) ) ,
598
599
"projectType" => Cow :: Owned ( project. type_of . to_string ( ) ) ,
@@ -738,10 +739,33 @@ impl<'graph> TokenExpander<'graph> {
738
739
} else {
739
740
let abs_path = path. to_logical_path ( & self . context . workspace_root ) ;
740
741
741
- path :: to_virtual_string ( diff_paths ( & abs_path, & self . project . root ) . unwrap_or ( abs_path) )
742
+ self . stringify_path ( & diff_paths ( & abs_path, & self . project . root ) . unwrap_or ( abs_path) )
742
743
}
743
744
}
744
745
746
+ fn stringify_path ( & self , orig_value : & Path ) -> miette:: Result < String > {
747
+ let value = path:: to_string ( orig_value) ?;
748
+
749
+ // https://cygwin.com/cygwin-ug-net/cygpath.html
750
+ #[ cfg( windows) ]
751
+ if env:: var ( "MSYSTEM" ) . is_ok_and ( |value| value == "MINGW32" || value == "MINGW64" ) {
752
+ let mut value = moon_common:: path:: standardize_separators ( value) ;
753
+
754
+ if orig_value. is_absolute ( ) {
755
+ for drive in 'A' ..='Z' {
756
+ if let Some ( suffix) = value. strip_prefix ( & format ! ( "{drive}:/" ) ) {
757
+ value = format ! ( "/{}/{suffix}" , drive. to_ascii_lowercase( ) ) ;
758
+ break ;
759
+ }
760
+ }
761
+ }
762
+
763
+ return Ok ( value) ;
764
+ }
765
+
766
+ Ok ( value)
767
+ }
768
+
745
769
fn infer_inputs ( & self , task : & mut Task , result : & ExpandedResult ) {
746
770
if task. options . infer_inputs {
747
771
task. input_files . extend ( result. files . clone ( ) ) ;
0 commit comments