@@ -26,7 +26,7 @@ const getBaseOptions = cb => {
2626 options . service_name = 'travis-ci' ;
2727 options . service_job_id = process . env . TRAVIS_JOB_ID ;
2828 options . service_pull_request = process . env . TRAVIS_PULL_REQUEST ;
29- git_commit = 'HEAD' ;
29+ git_commit = process . env . TRAVIS_COMMIT || 'HEAD' ;
3030 git_branch = process . env . TRAVIS_BRANCH ;
3131 }
3232
@@ -142,9 +142,6 @@ const getBaseOptions = cb => {
142142 }
143143
144144 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- }
148145
149146 if ( process . env . COVERALLS_SERVICE_JOB_ID ) {
150147 options . service_job_id = process . env . COVERALLS_SERVICE_JOB_ID ;
@@ -162,24 +159,41 @@ const getBaseOptions = cb => {
162159 options . parallel = true ;
163160 }
164161
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 = ( ( ) => {
170164 const yml = path . join ( process . cwd ( ) , '.coveralls.yml' ) ;
171165 try {
172166 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' ) ) ;
178168 }
179169 } 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 ;
182178 }
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 ;
183197 }
184198
185199 if ( process . env . COVERALLS_FLAG_NAME ) {
0 commit comments