1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

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>
This commit is contained in:
Bartek Iwańczuk 2023-05-23 19:35:12 +02:00 committed by GitHub
parent 8608105208
commit 3d865949c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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![