From 1a1ccb28415323876739b56764340c699ff94491 Mon Sep 17 00:00:00 2001 From: nicholaslyang Date: Mon, 28 Oct 2024 15:20:45 -0400 Subject: [PATCH] Add an extra canonicalization step for Windows because why make things easy when you can make them really annoying --- crates/turborepo-lib/src/query/file.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/turborepo-lib/src/query/file.rs b/crates/turborepo-lib/src/query/file.rs index ce21775108c385..58e4959dcb62ec 100644 --- a/crates/turborepo-lib/src/query/file.rs +++ b/crates/turborepo-lib/src/query/file.rs @@ -130,16 +130,20 @@ struct TraceResult { } impl TraceResult { - fn new(result: turbo_trace::TraceResult, run: Arc) -> Self { - Self { + fn new(result: turbo_trace::TraceResult, run: Arc) -> Result { + Ok(Self { files: result .files .into_iter() .sorted_by(|a, b| a.0.cmp(&b.0)) - .map(|(path, file)| File::new(run.clone(), path).with_ast(file.ast)) - .collect(), + .map(|(path, file)| { + #[cfg(windows)] + let path = AbsoluteSystemPathBuf::try_from(dunce::canonicalize(path)?)?; + Ok(File::new(run.clone(), path).with_ast(file.ast)) + }) + .collect::>()?, errors: result.errors.into_iter().map(|e| e.into()).collect(), - } + }) } } @@ -162,7 +166,11 @@ impl File { Ok(self.path.to_string()) } - async fn dependencies(&self, depth: Option, ts_config: Option) -> TraceResult { + async fn dependencies( + &self, + depth: Option, + ts_config: Option, + ) -> Result { let tracer = Tracer::new( self.run.repo_root().to_owned(), vec![self.path.clone()], @@ -175,7 +183,7 @@ impl File { TraceResult::new(result, self.run.clone()) } - async fn dependents(&self, ts_config: Option) -> TraceResult { + async fn dependents(&self, ts_config: Option) -> Result { let tracer = Tracer::new( self.run.repo_root().to_owned(), vec![self.path.clone()],