-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e74ef21
commit a793850
Showing
9 changed files
with
264 additions
and
175 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod import_finder; | ||
mod tracer; | ||
|
||
pub use tracer::{TraceError, Tracer}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::sync::Arc; | ||
|
||
use async_graphql::Object; | ||
use turbo_trace::Tracer; | ||
use turbopath::AbsoluteSystemPathBuf; | ||
|
||
use crate::{query::Error, run::Run}; | ||
|
||
pub struct File { | ||
run: Arc<Run>, | ||
path: AbsoluteSystemPathBuf, | ||
} | ||
|
||
impl File { | ||
pub fn new(run: Arc<Run>, path: AbsoluteSystemPathBuf) -> Self { | ||
Self { run, path } | ||
} | ||
} | ||
|
||
#[Object] | ||
impl File { | ||
async fn contents(&self) -> Result<String, Error> { | ||
let contents = self.path.read_to_string()?; | ||
Ok(contents) | ||
} | ||
|
||
async fn path(&self) -> Result<String, Error> { | ||
Ok(self | ||
.run | ||
.repo_root() | ||
.anchor(&self.path) | ||
.map(|path| path.to_string())?) | ||
} | ||
|
||
async fn absolute_path(&self) -> Result<String, Error> { | ||
Ok(self.path.to_string()) | ||
} | ||
|
||
async fn dependencies(&self) -> Result<Vec<File>, Error> { | ||
let tracer = Tracer::new( | ||
vec![self.path.clone()], | ||
self.run.repo_root().to_owned(), | ||
None, | ||
)?; | ||
let result = tracer.trace(); | ||
if !result.errors.is_empty() { | ||
return Err(Error::Trace(result.errors)); | ||
} | ||
|
||
Ok(result | ||
.files | ||
.into_iter() | ||
.map(|path| File::new(self.run.clone(), path)) | ||
.collect()) | ||
} | ||
} |
Oops, something went wrong.