Skip to content

Commit 504430f

Browse files
authored
feat: add test skip arg (#19)
1 parent d3dca06 commit 504430f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

main.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Run<T extends GlobalRunnerParams> = (
1717
t: Omit<T, keyof GlobalRunnerParams>,
1818
) => (pathname: string, logs: Buffer) => Promise<number>
1919

20-
const globalRunner = <T extends GlobalRunnerParams>(f: Run<T>) => {
20+
const globalRunner = <T extends GlobalRunnerParams>(f: Run<T>, skipArg: string) => {
2121
return async ({ concurrency, skip, ...rest }: T, includePatterns: string) => {
2222
const include: string[] = []
2323
for await (
@@ -44,7 +44,8 @@ const globalRunner = <T extends GlobalRunnerParams>(f: Run<T>) => {
4444
include.map((pathname) => async () => {
4545
const { frontmatter } = parseFrontmatter(pathname, await Deno.readTextFile(pathname), {
4646
test_skip(value) {
47-
return value !== undefined
47+
const skipArgs = new Set(value?.split(" ") ?? [])
48+
return value === "" || skipArgs.has(skipArg)
4849
},
4950
})
5051
const quotedPathname = `"${pathname}"`
@@ -92,15 +93,15 @@ await new Command()
9293
.command("deno")
9394
.arguments("<includePatterns..>")
9495
.option("-r, --reload <reload>", "reload")
95-
.action(globalRunner(runDeno))
96+
.action(globalRunner(runDeno, "deno"))
9697
.command("node")
9798
.arguments("<includePatterns..>")
98-
.action(globalRunner(runNode))
99+
.action(globalRunner(runNode, "node"))
99100
.command("browser")
100101
.arguments("<includePatterns..>")
101102
.option("-b, --browser <binary>", "browser binary")
102103
.option("-p, --project <project>", "project", { required: true })
103104
.option("-r, --reload <reload>", "reload", { required: true })
104-
.action(globalRunner(runBrowser)),
105+
.action(globalRunner(runBrowser, "browser")),
105106
)
106107
.parse(Deno.args)

0 commit comments

Comments
 (0)