@@ -26,19 +26,22 @@ export class ProfileService {
2626
2727 public async findProfile ( profileName : string ) : Promise < Profile > {
2828 return new Promise < Profile > ( ( resolve , reject ) => {
29- this . mapCelonisEnvProfile ( ) ;
30- this . checkIfMissingProfile ( profileName , reject ) ;
3129 try {
32- if ( process . env . TEAM_URL && process . env . API_TOKEN ) {
33- resolve ( this . buildProfileFromEnvVariables ( ) ) ;
34- } else {
30+ if ( ! this . checkIfMissingProfile ( profileName ) ) {
3531 const file = fs . readFileSync (
3632 path . resolve ( this . profileContainerPath , this . constructProfileFileName ( profileName ) ) ,
3733 { encoding : "utf-8" }
3834 ) ;
3935 const profile : Profile = JSON . parse ( file ) ;
4036 this . refreshProfile ( profile )
4137 . then ( ( ) => resolve ( profile ) ) ;
38+ } else if ( process . env . TEAM_URL && process . env . API_TOKEN ) {
39+ resolve ( this . buildProfileFromEnvVariables ( ) ) ;
40+ } else if ( process . env . CELONIS_URL && process . env . CELONIS_API_TOKEN ) {
41+ this . mapCelonisEnvProfile ( ) ;
42+ resolve ( this . buildProfileFromEnvVariables ( ) ) ;
43+ } else {
44+ reject ( `The profile ${ profileName } couldn't be resolved due to missing environment variables.` ) ;
4245 }
4346 } catch ( e ) {
4447 reject ( `The profile ${ profileName } couldn't be resolved.` ) ;
@@ -298,18 +301,18 @@ export class ProfileService {
298301 } )
299302 }
300303
301- private checkIfMissingProfile ( profileName : string , reject : any ) : void {
302- if ( ! profileName && ( ! process . env . TEAM_URL || ! process . env . API_TOKEN ) ) {
303- reject ( "Profile not found" ) ;
304+ private checkIfMissingProfile ( profileName : string ) : boolean {
305+ if ( ! profileName ) {
306+ return true ;
304307 }
305308 }
306309
307310 private mapCelonisEnvProfile ( ) : void {
308- if ( ! process . env . CELONIS_URL ) {
309- return ;
311+ let celonisUrl = process . env . CELONIS_URL ;
312+ if ( ! celonisUrl . startsWith ( "http://" ) && ! celonisUrl . startsWith ( "https://" ) ) {
313+ celonisUrl = `https://${ celonisUrl } ` ;
310314 }
311-
312- process . env . TEAM_URL = process . env . CELONIS_URL ;
315+ process . env . TEAM_URL = celonisUrl ;
313316
314317 if ( process . env . CELONIS_API_TOKEN ) {
315318 process . env . API_TOKEN = process . env . CELONIS_API_TOKEN ;
0 commit comments