Skip to content

Commit

Permalink
add if guard
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Nov 14, 2023
1 parent 709fcde commit cbcc869
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const githubContext = {

function getNameEmailInput(
input: string,
options: { required: true }
options: { required: true },
): [string, string];
function getNameEmailInput(
input: string,
options?: { required?: boolean }
options?: { required?: boolean },
): [string | null, string | null];
function getNameEmailInput(
input: string,
options: { required?: boolean } = {}
options: { required?: boolean } = {},
) {
const { required = false } = options;
const githubActionsRe = /^\s*@?github[-_]?actions(?:\[bot\])?\s*$/;
Expand Down Expand Up @@ -60,10 +60,12 @@ if (userName && userEmail) {
await $({ stdio: "inherit" })`git config --global user.email ${userEmail}`;
}

const prefix = new URL(githubServerURL).origin + "/";
await $({
stdio: "inherit",
})`git config --global http.${prefix}.extraheader ${`AUTHORIZATION: basic ${githubToken}`}`;
if (githubToken && githubServerURL) {
const prefix = new URL(githubServerURL).origin + "/";
await $({
stdio: "inherit",
})`git config --global http.${prefix}.extraheader ${`AUTHORIZATION: basic ${githubToken}`}`;
}

for (const safeDirectory of safeDirectories) {
await $({
Expand Down

0 comments on commit cbcc869

Please sign in to comment.