Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/core/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ export class ProfileService {

public async findProfile(profileName: string): Promise<Profile> {
return new Promise<Profile>((resolve, reject) => {
this.mapCelonisEnvProfile();
this.checkIfMissingProfile(profileName, reject);
try {
if (process.env.TEAM_URL && process.env.API_TOKEN) {
resolve(this.buildProfileFromEnvVariables());
} else {
if (!this.checkIfMissingProfile(profileName)) {
const file = fs.readFileSync(
path.resolve(this.profileContainerPath, this.constructProfileFileName(profileName)),
{ encoding: "utf-8" }
);
const profile : Profile = JSON.parse(file);
this.refreshProfile(profile)
.then(() => resolve(profile));
} else if (process.env.TEAM_URL && process.env.API_TOKEN) {
resolve(this.buildProfileFromEnvVariables());
} else {
this.mapCelonisEnvProfile();
resolve(this.buildProfileFromEnvVariables());
}
} catch (e) {
reject(`The profile ${profileName} couldn't be resolved.`);
Expand Down Expand Up @@ -298,9 +299,9 @@ export class ProfileService {
})
}

private checkIfMissingProfile(profileName: string, reject: any): void {
if (!profileName && (!process.env.TEAM_URL || !process.env.API_TOKEN)) {
reject("Profile not found");
private checkIfMissingProfile(profileName: string): boolean {
if (!profileName) {
return true;
}
}

Expand All @@ -309,7 +310,11 @@ export class ProfileService {
return;
}

process.env.TEAM_URL = process.env.CELONIS_URL;
let celonisUrl = process.env.CELONIS_URL;
if (!celonisUrl.startsWith("http://") && !celonisUrl.startsWith("https://")) {
celonisUrl = `https://${celonisUrl}`;
}
process.env.TEAM_URL = celonisUrl;

if (process.env.CELONIS_API_TOKEN) {
process.env.API_TOKEN = process.env.CELONIS_API_TOKEN;
Expand Down
Loading
Loading