Skip to content

Commit

Permalink
export types without pulling in React et al
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 27, 2019
1 parent 47c79a7 commit 17e93b9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ module.exports = (tap, reporter = 'base') => {
const Report = importJSX('./reports/' + reporter)
render(<Report tap={tap} />)
}

const fs = require('fs')
const types = module.exports.types = fs.readdirSync(__dirname + '/reports')
const types = module.exports.types = require('../types.js')
const cap = s => s.replace(/^./, $0 => $0.toUpperCase())
types.forEach(type =>
Object.defineProperty(module.exports, cap(type), {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"files": [
"index.js",
"types.js",
"lib/**/!(*.test).js"
],
"nyc": {
Expand Down
12 changes: 12 additions & 0 deletions tap-snapshots/types.test.js-TAP.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`types.test.js TAP > undefined 1`] = `
Array [
"base",
]
`
2 changes: 2 additions & 0 deletions types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const fs = require('fs')
module.exports = fs.readdirSync(__dirname + '/lib/reports')
2 changes: 2 additions & 0 deletions types.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const t = require('tap')
t.matchSnapshot(require('./types.js'))

0 comments on commit 17e93b9

Please sign in to comment.