|
1 | 1 | import * as path from "@std/path"; |
2 | 2 | import { assertEquals, assertRejects } from "@std/assert"; |
3 | | -import { getDntVersion, runCommand, valueToUrl } from "./utils.ts"; |
| 3 | +import { getDntVersion, glob, runCommand, valueToUrl } from "./utils.ts"; |
| 4 | + |
| 5 | +Deno.test("glob should not search node_modules or excluded dirs", async () => { |
| 6 | + const rootDir = await Deno.makeTempDir(); |
| 7 | + try { |
| 8 | + const testFilePaths = [ |
| 9 | + ["mod.test.ts"], |
| 10 | + ["sub", "mod.test.ts"], |
| 11 | + ["node_modules", "pkg", "mod.test.ts"], |
| 12 | + ["sub", "node_modules", "pkg", "mod.test.ts"], |
| 13 | + ["npm", "mod.test.ts"], |
| 14 | + ]; |
| 15 | + for (const filePath of testFilePaths) { |
| 16 | + const absPath = path.join(rootDir, ...filePath); |
| 17 | + await Deno.mkdir(path.dirname(absPath), { recursive: true }); |
| 18 | + await Deno.writeTextFile(absPath, ""); |
| 19 | + } |
| 20 | + |
| 21 | + const paths = await glob({ |
| 22 | + pattern: "**/*.test.ts", |
| 23 | + rootDir, |
| 24 | + excludeDirs: [path.join(rootDir, "npm")], |
| 25 | + }); |
| 26 | + |
| 27 | + assertEquals( |
| 28 | + paths.map((p) => path.relative(rootDir, p)).sort(), |
| 29 | + ["mod.test.ts", path.join("sub", "mod.test.ts")], |
| 30 | + ); |
| 31 | + } finally { |
| 32 | + await Deno.remove(rootDir, { recursive: true }); |
| 33 | + } |
| 34 | +}); |
4 | 35 |
|
5 | 36 | Deno.test({ |
6 | 37 | name: "should error when command doesn't exist", |
|
0 commit comments