Skip to content

Commit daed588

Browse files
authored
fix(config): regression - handle relative patterns with leading dot slash (#21922)
This is a hacky quick fix. We need to spend more time cleaning up this code and push more stuff down into deno_config. Closes #21916
1 parent 0b9c06b commit daed588

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

cli/tests/integration/test_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,3 +663,9 @@ fn conditionally_loads_type_graph() {
663663
.run();
664664
assert_not_contains!(output.combined_output(), "type_reference.d.ts");
665665
}
666+
667+
itest!(test_include_relative_pattern_dot_slash {
668+
args: "test",
669+
output: "test/relative_pattern_dot_slash/output.out",
670+
cwd: Some("test/relative_pattern_dot_slash"),
671+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"test": {
3+
"include": [
4+
"./test/**/*.test.mjs"
5+
]
6+
}
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
running 1 test from ./test/add.test.mjs
2+
should add ... ok ([WILDCARD])
3+
4+
ok | 1 passed | 0 failed ([WILDCARD])
5+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function add(a, b) {
2+
return a + b;
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { add } from "./add.mjs";
2+
3+
Deno.test("should add", () => {
4+
if (add(1, 2) !== 3) {
5+
throw new Error("FAIL");
6+
}
7+
});

cli/util/glob.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ impl GlobPattern {
248248
}
249249

250250
pub fn new(pattern: &str) -> Result<Self, AnyError> {
251-
let pattern =
252-
glob::Pattern::new(&escape_brackets(pattern).replace('\\', "/"))
253-
.with_context(|| format!("Failed to expand glob: \"{}\"", pattern))?;
251+
let pattern = escape_brackets(pattern)
252+
.replace('\\', "/")
253+
.replace("/./", "/");
254+
let pattern = glob::Pattern::new(&pattern)
255+
.with_context(|| format!("Failed to expand glob: \"{}\"", pattern))?;
254256
Ok(Self(pattern))
255257
}
256258

0 commit comments

Comments
 (0)