diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2023-05-23 19:35:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-23 17:35:12 +0000 |
commit | 3d865949c2f9f0cb61031bcc2b9e81a4ca623109 (patch) | |
tree | 7efab61647b22dd0458c0d64921f85164ac9b94a | |
parent | 86081052089edbcc2ef2a76ea950ae58f46066b3 (diff) |
fix: better error message for malformed glob (#19225)
Before:
```
$ cargo run -- test "foo/*******/bar.ts"
error: Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**`
```
After:
```
$ cargo run -- test "foo/*******/bar.ts"
error: Failed to expand glob: "foo/*******/bar.ts"
Caused by:
Pattern syntax error near position 6: wildcards are either regular `*` or recursive `**`
```
---------
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
-rw-r--r-- | cli/args/mod.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 513d4b39e..8b3d79308 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1343,7 +1343,8 @@ fn expand_globs(paths: &[PathBuf]) -> Result<Vec<PathBuf>, AnyError> { // true because it copies with sh does—these files are considered "hidden" require_literal_leading_dot: true, }, - )?; + ) + .with_context(|| format!("Failed to expand glob: \"{}\"", path_str))?; for globbed_path_result in globbed_paths { new_paths.push(globbed_path_result?); @@ -1592,6 +1593,16 @@ mod test { temp_dir.write("pages/[id].ts", ""); + let error = resolve_files( + Some(FilesConfig { + include: vec![temp_dir.path().join("data/**********.ts")], + exclude: vec![], + }), + None, + ) + .unwrap_err(); + assert!(error.to_string().starts_with("Failed to expand glob")); + let resolved_files = resolve_files( Some(FilesConfig { include: vec![ |