borp 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/borp.js CHANGED
@@ -90,9 +90,7 @@ try {
90
90
 
91
91
  const reporters = {
92
92
  ...Reporters,
93
- gh: githubReporter,
94
- /* eslint new-cap: "off" */
95
- spec: new Reporters.spec()
93
+ gh: githubReporter
96
94
  }
97
95
 
98
96
  // If we're running in a GitHub action, adds the gh reporter
@@ -103,10 +101,8 @@ try {
103
101
 
104
102
  for (const input of args.values.reporter) {
105
103
  const [name, dest] = input.split(':')
106
- const reporter = reporters[name]
107
- if (!reporter) {
108
- throw new Error(`Unknown reporter: ${name}`)
109
- }
104
+ const Ctor = reporters[name] || await import(name).then((m) => m.default || m)
105
+ const reporter = Object.getOwnPropertyDescriptor(Ctor.prototype, 'constructor') ? new Ctor() : Ctor
110
106
  let output = process.stdout
111
107
  if (dest) {
112
108
  output = createWriteStream(dest)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "borp",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "node:test wrapper with TypeScript support",
6
6
  "main": "borp.js",
@@ -22,6 +22,7 @@
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
24
  "@matteo.collina/tspl": "^0.1.0",
25
+ "@reporters/silent": "^1.2.4",
25
26
  "@types/node": "^20.10.0",
26
27
  "desm": "^1.3.0",
27
28
  "snazzy": "^9.0.0",
package/test/cli.test.js CHANGED
@@ -60,3 +60,18 @@ test('disable ts and run no tests', async () => {
60
60
 
61
61
  strictEqual(stdout.indexOf('tests 0') >= 0, true)
62
62
  })
63
+
64
+ test('reporter from node_modules', async () => {
65
+ const cwd = join(import.meta.url, '..', 'fixtures', 'ts-esm2')
66
+ await rm(path.join(cwd, 'dist'), { recursive: true, force: true })
67
+ const { stdout } = await execa('node', [
68
+ borp,
69
+ '--reporter=spec',
70
+ '--reporter=@reporters/silent',
71
+ '--no-typescript'
72
+ ], {
73
+ cwd
74
+ })
75
+
76
+ strictEqual(stdout.indexOf('tests 0') >= 0, true)
77
+ })