mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 08:02:15 -05:00
feat(cli): Strip .in
suffix(es)
`.in` is typically used for build system template input files, containing some placeholders to replace. In some cases, multiple rounds of replacements are used, each with their own `.in`, so remove all trailing instances of it before attempting a filename match. Closes https://github.com/crate-ci/typos/issues/727
This commit is contained in:
parent
38a1b19481
commit
90d4676dd7
1 changed files with 3 additions and 1 deletions
|
@ -107,7 +107,7 @@ impl Types {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn file_matched(&self, path: &std::path::Path) -> Option<&str> {
|
pub fn file_matched(&self, path: &std::path::Path) -> Option<&str> {
|
||||||
let file_name = path.file_name()?;
|
let file_name = path.file_name()?.to_str()?.trim_end_matches(".in");
|
||||||
let mut matches = self.matches.get_or_default().borrow_mut();
|
let mut matches = self.matches.get_or_default().borrow_mut();
|
||||||
self.set.matches_into(file_name, &mut *matches);
|
self.set.matches_into(file_name, &mut *matches);
|
||||||
matches
|
matches
|
||||||
|
@ -153,6 +153,8 @@ mod tests {
|
||||||
matched!(multi_def_2, types(), "index.htm", "html");
|
matched!(multi_def_2, types(), "index.htm", "html");
|
||||||
matched!(no_match, types(), "leftpad.ada", None);
|
matched!(no_match, types(), "leftpad.ada", None);
|
||||||
matched!(more_specific, types(), "package-lock.json", "lock");
|
matched!(more_specific, types(), "package-lock.json", "lock");
|
||||||
|
matched!(trailing_in, types(), "index.html.in", "html");
|
||||||
|
matched!(trailing_in_in, types(), "index.html.in.in", "html");
|
||||||
|
|
||||||
macro_rules! sort {
|
macro_rules! sort {
|
||||||
($name:ident, $actual:expr, $expected:expr) => {
|
($name:ident, $actual:expr, $expected:expr) => {
|
||||||
|
|
Loading…
Reference in a new issue