@@ -8,29 +8,31 @@ var supportsColor = require('supports-color')
8
8
var nycBin = require . resolve ( 'nyc/bin/nyc.js' )
9
9
var glob = require ( 'glob' )
10
10
var isexe = require ( 'isexe' )
11
+ var osHomedir = require ( 'os-homedir' )
12
+ var extend = require ( 'deep-extend' )
13
+ var yaml = require ( 'js-yaml' )
14
+ var parseRcFile = require ( './utils' ) . parseRcFile
11
15
12
16
var coverageServiceTest = process . env . COVERAGE_SERVICE_TEST === 'true'
13
17
14
18
// console.error(process.argv.join(' '))
15
19
// console.error('CST=%j', process.env.COVERAGE_SERVICE_TEST)
16
20
// console.error('CRT=%j', process.env.COVERALLS_REPO_TOKEN)
17
- // console.error('CCT=%j', process.env.CODECOV_TOKEN)
18
21
if ( coverageServiceTest ) {
19
22
console . log ( 'COVERAGE_SERVICE_TEST' )
20
23
}
21
24
22
25
// Add new coverage services here.
23
26
// it'll check for the environ named and pipe appropriately.
27
+ //
28
+ // Currently only Coveralls is supported, but the infrastructure
29
+ // is left in place in case some noble soul fixes the codecov
30
+ // module in the future. See https://github.com/tapjs/node-tap/issues/270
24
31
var coverageServices = [
25
32
{
26
33
env : 'COVERALLS_REPO_TOKEN' ,
27
34
bin : require . resolve ( 'coveralls/bin/coveralls.js' ) ,
28
35
name : 'Coveralls'
29
- } ,
30
- {
31
- env : 'CODECOV_TOKEN' ,
32
- bin : require . resolve ( 'codecov.io/bin/codecov.io.js' ) ,
33
- name : 'Codecov'
34
36
}
35
37
]
36
38
@@ -44,7 +46,17 @@ function main () {
44
46
process . exit ( 1 )
45
47
}
46
48
47
- var options = parseArgs ( args )
49
+ // set default args
50
+ var defaults = constructDefaultArgs ( )
51
+
52
+ // parse dotfile
53
+ var rcOptions = parseRcFile ( osHomedir ( ) + '/.taprc' )
54
+
55
+ // supplement defaults with parsed rc options
56
+ defaults = extend ( defaults , rcOptions )
57
+
58
+ // parse args
59
+ var options = parseArgs ( args , defaults )
48
60
49
61
if ( ! options ) {
50
62
return
@@ -93,26 +105,34 @@ function main () {
93
105
runTests ( options )
94
106
}
95
107
96
- function parseArgs ( args ) {
97
- var options = { }
108
+ function constructDefaultArgs ( ) {
109
+ var defaultArgs = {
110
+ nodeArgs : [ ] ,
111
+ nycArgs : [ ] ,
112
+ timeout : process . env . TAP_TIMEOUT || 30 ,
113
+ color : supportsColor ,
114
+ reporter : null ,
115
+ files : [ ] ,
116
+ bail : false ,
117
+ saveFile : null ,
118
+ pipeToService : false ,
119
+ coverageReport : null ,
120
+ openBrowser : true
121
+ }
98
122
99
- options . nodeArgs = [ ]
100
- options . nycArgs = [ ]
101
- options . timeout = process . env . TAP_TIMEOUT || 30
102
- // coverage tools run slow.
103
- /* istanbul ignore else */
104
123
if ( global . __coverage__ ) {
105
- options . timeout = 240
124
+ defaultArgs . timeout = 240
106
125
}
107
126
108
- options . color = supportsColor
109
127
if ( process . env . TAP_COLORS !== undefined ) {
110
- options . color = ! ! ( + process . env . TAP_COLORS )
128
+ defaultArgs . color = ! ! ( + process . env . TAP_COLORS )
111
129
}
112
- options . reporter = null
113
- options . files = [ ]
114
- options . bail = false
115
- options . saveFile = null
130
+
131
+ return defaultArgs
132
+ }
133
+
134
+ function parseArgs ( args , defaults ) {
135
+ var options = defaults || { }
116
136
117
137
var singleFlags = {
118
138
b : 'bail' ,
@@ -131,7 +151,6 @@ function parseArgs (args) {
131
151
132
152
// If we're running under Travis-CI with a Coveralls.io token,
133
153
// then it's a safe bet that we ought to output coverage.
134
- options . pipeToService = false
135
154
for ( var i = 0 ; i < coverageServices . length && ! options . pipeToService ; i ++ ) {
136
155
if ( process . env [ coverageServices [ i ] . env ] ) {
137
156
options . pipeToService = true
@@ -140,9 +159,6 @@ function parseArgs (args) {
140
159
141
160
var defaultCoverage = options . pipeToService
142
161
143
- options . coverageReport = null
144
- options . openBrowser = true
145
-
146
162
for ( i = 0 ; i < args . length ; i ++ ) {
147
163
var arg = args [ i ]
148
164
if ( arg . charAt ( 0 ) !== '-' || arg === '-' ) {
@@ -428,7 +444,7 @@ function runCoverageReportOnly (options, code, signal) {
428
444
// console.error('run coverage report', args)
429
445
430
446
var child
431
- // automatically hook into coveralls and/or codecov
447
+ // automatically hook into coveralls
432
448
if ( options . coverageReport === 'text-lcov' && options . pipeToService ) {
433
449
// console.error('pipeToService')
434
450
child = spawn ( node , args , { stdio : [ 0 , 'pipe' , 2 ] } )
0 commit comments