-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.ts
70 lines (69 loc) · 1.91 KB
/
cli.ts
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
65
66
67
68
69
70
import d8 from "./mod.ts";
import { colors, Command } from "./deps.ts";
import { VERSION } from "./version.ts";
const { gray, italic } = colors;
await new Command()
.name("d8")
.version(VERSION)
.description("Brings istanbul's rich test coverage reporting to deno")
.example(
`Install`,
[
gray(italic(`# install d8:`)),
`deno install --allow-read --allow-write --unstable -n d8 https://x.nest.land/d8@${VERSION}/cli.ts`,
` `,
].join("\n")
)
.example(
`Report`,
[
``,
gray(italic(`# collect deno coverage`)),
`deno test --coverage=coverage/deno`,
``,
gray(italic(`# convert to c8 format`)),
`d8 convert coverage/deno coverage/tmp`,
``,
gray(italic(`# generate reports with c8`)),
`npx c8 report -r html`,
` `,
].join(`\n`)
)
.example(
`Report & Coverage`,
[
``,
gray(italic(`# collect deno coverage`)),
`deno test --coverage=coverage/deno`,
``,
gray(italic(`# convert to c8 format`)),
`d8 convert coverage/deno coverage/tmp`,
``,
gray(italic(`# report & threshold checks`)),
`npx c8 report -r html --check-coverage --per-file`,
gray(italic(`# (see c8 docs for more details)`)),
` `,
].join(`\n`)
)
.command(
"convert <deno-dir:string> <c8-dir:string>",
new Command()
.description(`convert deno's coverage data format to c8's format`)
.option(`--clean`, "Clean <c8_dir> before conversion")
.option(`--trace`, "Provide a trace of execution details", {
hidden: true,
})
.action(async (options, ...args) => {
const [denoDir, c8Dir] = [...args].map((p: string) =>
`${Deno.cwd()}/${p}`.replace(/\\+/g, "/")
);
const { clean, trace } = options;
await d8({
denoDir,
c8Dir,
clean,
trace,
});
})
)
.parse(Deno.args);