Repository navigation
Expand file tree
/
Copy pathtest_docs.ts
More file actions
64 lines (55 loc) · 1.35 KB
/
Copy pathtest_docs.ts
File metadata and controls
64 lines (55 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { globber, Meta } from "../mod.ts";
import { path } from "../src/deps.ts";
import { semver } from "./deps.ts";
const cwd = new URL("../", import.meta.url).pathname;
const importMapPath = path.join(cwd, "tests/test_docs_import_map.json");
semver.inc;
const releaseTypes = [
"pre",
"major",
"premajor",
"minor",
"preminor",
"patch",
"prepatch",
"prerelease",
] as const;
try {
const imports: Record<string, string> = {
"https://deno.land/x/globber@<%=it.version%>/": cwd,
"https://deno.land/x/globber/": cwd,
[`https://deno.land/x/globber@${Meta.VERSION}/`]: cwd,
};
for (const type of releaseTypes) {
imports[`https://deno.land/x/globber@${semver.inc(Meta.VERSION, type)}/`] =
cwd;
}
const importMap = { imports };
const files = [];
for await (
const file of globber({
cwd,
extensions: [".ts", ".md"],
exclude: ["**/fixtures/", "**/tests/", "**/scripts/"],
excludeDirectories: true,
})
) {
files.push(file.relative);
}
await Deno.writeTextFile(importMapPath, JSON.stringify(importMap));
await Deno
.run({
cmd: [
"deno",
"test",
"--doc",
"--check",
`--allow-read=${cwd}`,
`--import-map=${importMapPath}`,
...files,
],
cwd,
}).status();
} finally {
await Deno.remove(importMapPath);
}