fix(nix): resolve linter paths under bazel run
This commit is contained in:
@@ -66,7 +66,8 @@ pub fn run(
|
||||
let mut found_tool_errors = false;
|
||||
|
||||
for path in paths {
|
||||
match collect_nix_files(path) {
|
||||
let path = resolve_workspace_path(path);
|
||||
match collect_nix_files(&path) {
|
||||
Ok(files) => {
|
||||
for file in files {
|
||||
match lint_file(&file) {
|
||||
@@ -103,6 +104,18 @@ pub fn run(
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_workspace_path(path: &Path) -> PathBuf {
|
||||
if path.is_absolute() {
|
||||
return path.to_path_buf();
|
||||
}
|
||||
|
||||
if let Some(workspace) = std::env::var_os("BUILD_WORKSPACE_DIRECTORY") {
|
||||
return PathBuf::from(workspace).join(path);
|
||||
}
|
||||
|
||||
path.to_path_buf()
|
||||
}
|
||||
|
||||
pub fn lint_file(path: &Path) -> io::Result<Vec<Diagnostic>> {
|
||||
let source = fs::read_to_string(path)?;
|
||||
let parse = rnix::Root::parse(&source);
|
||||
|
||||
Reference in New Issue
Block a user