@@ -26,7 +26,7 @@ const getBaseOptions = cb => {
26
26
options . service_name = 'travis-ci' ;
27
27
options . service_job_id = process . env . TRAVIS_JOB_ID ;
28
28
options . service_pull_request = process . env . TRAVIS_PULL_REQUEST ;
29
- git_commit = 'HEAD' ;
29
+ git_commit = process . env . TRAVIS_COMMIT || 'HEAD' ;
30
30
git_branch = process . env . TRAVIS_BRANCH ;
31
31
}
32
32
@@ -142,9 +142,6 @@ const getBaseOptions = cb => {
142
142
}
143
143
144
144
options . run_at = process . env . COVERALLS_RUN_AT || JSON . stringify ( new Date ( ) ) . slice ( 1 , - 1 ) ;
145
- if ( process . env . COVERALLS_SERVICE_NAME ) {
146
- options . service_name = process . env . COVERALLS_SERVICE_NAME ;
147
- }
148
145
149
146
if ( process . env . COVERALLS_SERVICE_JOB_ID ) {
150
147
options . service_job_id = process . env . COVERALLS_SERVICE_JOB_ID ;
@@ -162,24 +159,41 @@ const getBaseOptions = cb => {
162
159
options . parallel = true ;
163
160
}
164
161
165
- // try to get the repo token as an environment variable
166
- if ( process . env . COVERALLS_REPO_TOKEN ) {
167
- options . repo_token = process . env . COVERALLS_REPO_TOKEN ;
168
- } else {
169
- // try to get the repo token from a .coveralls.yml file
162
+ // load a .coveralls.yml file
163
+ const coveralls_yaml_conf = ( ( ) => {
170
164
const yml = path . join ( process . cwd ( ) , '.coveralls.yml' ) ;
171
165
try {
172
166
if ( fs . statSync ( yml ) . isFile ( ) ) {
173
- const coveralls_yaml_conf = yaml . safeLoad ( fs . readFileSync ( yml , 'utf8' ) ) ;
174
- options . repo_token = coveralls_yaml_conf . repo_token ;
175
- if ( coveralls_yaml_conf . service_name ) {
176
- options . service_name = coveralls_yaml_conf . service_name ;
177
- }
167
+ return yaml . safeLoad ( fs . readFileSync ( yml , 'utf8' ) ) ;
178
168
}
179
169
} catch ( _ ) {
180
- logger . warn ( 'Repo token could not be determined. Continuing without it. ' +
181
- 'This is necessary for private repos only, so may not be an issue at all.' ) ;
170
+ logger . debug ( 'No valid .coveralls.yml file found' ) ;
171
+ }
172
+ } ) ( ) ;
173
+
174
+ // try to get repo token and service name from .coveralls.yml file
175
+ if ( coveralls_yaml_conf ) {
176
+ if ( coveralls_yaml_conf . repo_token ) {
177
+ options . repo_token = coveralls_yaml_conf . repo_token ;
182
178
}
179
+ if ( coveralls_yaml_conf . service_name ) {
180
+ options . service_name = coveralls_yaml_conf . service_name ;
181
+ }
182
+ }
183
+
184
+ // try to get the repo token as an environment variable
185
+ if ( process . env . COVERALLS_REPO_TOKEN ) {
186
+ options . repo_token = process . env . COVERALLS_REPO_TOKEN ;
187
+ }
188
+
189
+ if ( 'travis-pro' === options . service_name && ! options . repo_token ) {
190
+ logger . warn ( 'Repo token could not be determined. Continuing without it. ' +
191
+ 'This is necessary for private repos only, so may not be an issue at all.' ) ;
192
+ }
193
+
194
+ // try to get the service name as an environment variable
195
+ if ( process . env . COVERALLS_SERVICE_NAME ) {
196
+ options . service_name = process . env . COVERALLS_SERVICE_NAME ;
183
197
}
184
198
185
199
if ( process . env . COVERALLS_FLAG_NAME ) {
0 commit comments