Skip to content

Commit

Permalink
Merge pull request github-community-projects#141 from github-communit…
Browse files Browse the repository at this point in the history
…y-projects/ajhenry/update-org-config-fallback

Perform proper checks for empty env configs
  • Loading branch information
ajhenry authored May 9, 2024
2 parents f85a4ec + b38a5ec commit 9441be8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ try {
console.log(e);
}

if (!process.env.ORGANIZATION_NAME && !yamlConfig.organization) {
const envOrganizationName = process.env.ORGANIZATION_NAME;
const configOrganizationName = yamlConfig.organization;

if (!envOrganizationName && !configOrganizationName) {
console.log(
'ORGANIZATION_NAME environment variable or `organization` in config.yml is required',
);
Expand All @@ -83,7 +86,10 @@ const config: Config = {
includeArchived: false,
...yamlConfig,
// You can override the organization in an env variable ORGANIZATION_NAME
organization: process.env.ORGANIZATION_NAME ?? yamlConfig.organization ?? '',
organization:
(envOrganizationName && envOrganizationName?.length !== 0
? envOrganizationName
: configOrganizationName) ?? '',
// Default since date is 365 days ago (1 year)
since: yamlConfig.since
? new Date(yamlConfig.since).toISOString()
Expand Down

0 comments on commit 9441be8

Please sign in to comment.