Skip to content

Commit

Permalink
readd explicit null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
afujiwara-roblox committed Oct 3, 2023
1 parent 714bec1 commit 4f326f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/configFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ function checkSameOrgToolSpecs(
org: string
): boolean {
const tools = manifestContent.tools;
if (!tools) {
if (tools == null) {
throw new Error("Tools section in Foreman config not found");
}

for (const tool_name in tools) {
const tool_spec = tools[tool_name];
let source = tool_spec["source"];
if (!source) {
if (source == undefined) {
source = tool_spec["github"];
}
if (!source) {
if (source == undefined) {
continue;
}

const source_array = source.split("/");
const tool_org = source_array[0];

if (!tool_org) {
if (tool_org == null) {
throw new Error(
`Org not found in tool spec definition for: ${tool_name}. Foreman config is likely defined incorrectly.`
);
Expand All @@ -52,7 +52,7 @@ function checkSameOrgToolSpecs(

async function checkSameOrgInConfig(org: string): Promise<void> {
const manifestPath = await findUp(MANIFEST);
if (!manifestPath) {
if (manifestPath == undefined) {
throw new Error("setup-foreman could not find Foreman config file");
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function run(): Promise<void> {
if (allowExternalGithubOrgs != "true") {
debug("Checking tools in Foreman Config come from source org");
const owner = process.env.GITHUB_REPOSITORY_OWNER;
if (!owner) {
if (owner == undefined) {
throw new Error(
`Could not find repository owner setup-foreman is running in`
);
Expand Down

0 comments on commit 4f326f0

Please sign in to comment.