From 0bc07a11fae65173b852b828196f333e20907a09 Mon Sep 17 00:00:00 2001 From: liquidev Date: Mon, 25 Mar 2024 17:08:56 +0100 Subject: [PATCH] fix fix touching non-tree files --- crates/treehouse/src/cli/fix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/treehouse/src/cli/fix.rs b/crates/treehouse/src/cli/fix.rs index 8992c0b..1e48753 100644 --- a/crates/treehouse/src/cli/fix.rs +++ b/crates/treehouse/src/cli/fix.rs @@ -1,4 +1,4 @@ -use std::ops::Range; +use std::{ffi::OsStr, ops::Range}; use anyhow::Context; use treehouse_format::ast::Branch; @@ -154,7 +154,7 @@ pub fn fix_file_cli(fix_args: FixArgs) -> anyhow::Result<()> { pub fn fix_all_cli(fix_all_args: FixAllArgs, paths: &Paths<'_>) -> anyhow::Result<()> { for entry in WalkDir::new(paths.content_dir) { let entry = entry?; - if entry.file_type().is_file() { + if entry.file_type().is_file() && entry.path().extension() == Some(OsStr::new("tree")) { let file = std::fs::read_to_string(entry.path()) .with_context(|| format!("cannot read file to fix: {:?}", entry.path()))?; let utf8_filename = entry.path().to_string_lossy();