Allow to use "." as the input directory.

This commit is contained in:
Pedro de Oliveira 2023-05-08 01:17:53 +01:00
parent 321bd8c50b
commit 29fa9f5499
1 changed files with 5 additions and 5 deletions

View File

@ -42,8 +42,8 @@ struct Args {
}
fn get_file_list(dir_path: &str, wildcard: &str) -> Vec<String> {
let pattern = format!("{}/{}", dir_path, wildcard);
let dir_entries: Vec<Result<PathBuf, _>> = glob(&pattern).unwrap().collect();
let pattern = Path::new(dir_path).join(wildcard);
let dir_entries: Vec<Result<PathBuf, _>> = glob(&pattern.to_string_lossy()).unwrap().collect();
dir_entries
.into_iter()
.filter_map(|entry| entry.ok())
@ -137,10 +137,10 @@ fn full_name_test() {
#[test]
fn file_list_test() {
const DIRECTORY: &str = "src";
const WILDCARD: &str = "*.rs";
const DIRECTORY: &str = ".";
const WILDCARD: &str = "*.toml";
assert_eq!(get_file_list(DIRECTORY, WILDCARD), vec!["main.rs"]);
assert_eq!(get_file_list(DIRECTORY, WILDCARD), vec!["Cargo.toml"]);
}
#[test]