Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit 231a9a7

Browse files
committed
feat!: remove "fancy" reporter and --reporter option, add --color for default tap reporter
1 parent 2fc0911 commit 231a9a7

File tree

9 files changed

+206
-270
lines changed

9 files changed

+206
-270
lines changed

bin/tsd-lite.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env node
22

33
import fastGlob from "fast-glob"
4-
import { Option, program } from "commander"
5-
6-
import tapReporter from "../lib/reporters/tap.js"
7-
import fancyReporter from "../lib/reporters/fancy.js"
4+
import { program } from "commander"
85

6+
import tapReporter from "../lib/run-one.tap-reporter.js"
97
import { getNodeVersion, getPackageInfo } from "../lib/utils/node.js"
10-
import { green, red } from "../lib/utils/colors.js"
11-
import { runSuite } from "../lib/runSuite.js"
8+
import { green, red } from "../lib/utils/terminal-text.js"
9+
import { runSuite } from "../lib/run-many.js"
1210

1311
/**
1412
* Node.js version guard
@@ -33,36 +31,42 @@ if (major < required) {
3331

3432
const { description, version } = await getPackageInfo()
3533
const processStartAt = process.hrtime()
34+
const isCI = process.env["CI"] === "true"
3635

3736
program
3837
.name("tsd-lite")
3938
.description(description)
4039
.version(version, "-v, --version", "Print version number")
4140
.helpOption("-h, --help", "Print this help guide")
4241
.showSuggestionAfterError()
43-
.addOption(
44-
new Option("-r, --reporter <name>", "Print test results using reporter")
45-
.default("tap")
46-
.choices(["tap", "fancy"])
42+
.option(
43+
"-c, --color",
44+
"Output colored TAP for better human consumption. Disabled in CI environments if not explicitly set.",
45+
!isCI
46+
)
47+
.option(
48+
"--no-color",
49+
"Dont output colored TAP, usefull when piping to other tools"
4750
)
48-
.argument("patterns...", "Glob patterns for matching test files")
49-
.action(async (patterns, { reporter: reporterName }) => {
50-
const reporter = reporterName === "tap" ? tapReporter : fancyReporter
51+
.argument("<patterns...>", "Glob patterns for matching test files")
52+
.action(async (patterns, { color: hasColor }) => {
5153
const files = fastGlob.sync(patterns, { absolute: true })
5254

5355
process.stdout.write(
54-
`${reporter.formatIntro({
56+
`${tapReporter.formatIntro({
5557
count: files.length,
5658
patterns,
59+
hasColor,
5760
})}\n`
5861
)
5962

6063
runSuite(files, {
6164
onTestFinish: (result, index) => {
6265
process.stdout.write(
63-
`${reporter.formatTest({
66+
`${tapReporter.formatTest({
6467
index,
6568
result,
69+
hasColor,
6670
})}\n`
6771
)
6872
},
@@ -82,10 +86,11 @@ program
8286
)
8387

8488
process.stdout.write(
85-
`\n${reporter.formatSuite({
89+
`\n${tapReporter.formatSuite({
8690
passCount,
8791
failCount,
8892
duration: process.hrtime(processStartAt),
93+
hasColor,
8994
})}\n`
9095
)
9196

lib/reporters/_signature.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/reporters/fancy.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

lib/reporters/tap.js

Lines changed: 0 additions & 109 deletions
This file was deleted.

lib/runSuite.js renamed to lib/run-many.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/** @typedef {import("./runTest.js").TestResult} TestResult */
1+
/** @typedef {import("./run-one").TestResult} TestResult */
22

3-
import { runTest } from "./runTest.js"
3+
import { runTest } from "./run-one.js"
44

55
/**
66
* @callback OnTestFinish
File renamed without changes.

0 commit comments

Comments
 (0)