Skip to content

Commit

Permalink
fmt: format files with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] committed Nov 16, 2023
1 parent cd16256 commit aa3e244
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const toMarkdownTable = (tbl) =>
.toString()
.replace(/([\\]+)\|/gu, "$1$1|")
.replace(/\|/gu, "\\|")
.trim()
.trim(),
)
.join(" | ")} |`
.join(" | ")} |`,
)
.join("\n");

Expand All @@ -47,15 +47,15 @@ ${usageFile
process.env.npm_package_version ||
error("unable to get package version from env var $npm_package_version")
).match(/^.*?[1-9]/u)[0]
}`
}`,
)
.replace(/^\n+|\n+$/gu, "")}
~~~`,

inputsTable: () => {
const table = [
["Key", "Description", "Required", "Default"].map(
(title) => `**${title}**`
(title) => `**${title}**`,
),
];

Expand Down Expand Up @@ -85,7 +85,7 @@ ${usageFile

const readme = (await readFile("README_TEMPLATE.md", "utf8")).replace(
/<!--.*?@include\s+(\S+).*?-->/gmu,
(m, p1) => snippets[p1]?.() || error("unrecognized @include directive: " + m)
(m, p1) => snippets[p1]?.() || error("unrecognized @include directive: " + m),
);

await writeFile(
Expand All @@ -95,5 +95,5 @@ await writeFile(
...(await prettier.resolveConfig(readmeFilePath, {
useCache: false,
})),
})
}),
);
6 changes: 3 additions & 3 deletions scripts/fix-sourcemap-sources.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ json.sources = json.sources.map((path) =>
path.replace(
new RegExp(
`^(?:\\.\\.?[\\\\/])*webpack:[\\\\/]*(?:breaking-change[\\\\/])?`,
"u"
"u",
),
""
)
"",
),
);

await writeFile(file, JSON.stringify(json));
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ try {
assert(
Array.isArray(ret),
`"commits" field of event payload is the wrong type: expected "Array", found "${humanReadableTypeOf(
ret
)}"`
ret,
)}"`,
);

return ret.filter((cm) => filterFn(cm.message));
Expand All @@ -58,13 +58,13 @@ try {

assert(
inputWasProvided(issueNumber) || inputWasProvided(discussionNumber),
'missing input: one or both of "discussionNumber" or "issueNumber" must be provided'
'missing input: one or both of "discussionNumber" or "issueNumber" must be provided',
);

if (inputWasProvided(issueNumber)) {
assert(
/^\d+$/.test(issueNumber),
'invalid input provided for "issueNumber": not a valid integer'
'invalid input provided for "issueNumber": not a valid integer',
);

issueNumber = parseInt(issueNumber, 10);
Expand All @@ -74,8 +74,8 @@ try {
assert(
/^\d+$/.test(
discussionNumber,
'invalid input provided for "discussionNumber": not a valid integer'
)
'invalid input provided for "discussionNumber": not a valid integer',
),
);

discussionNumber = parseInt(discussionNumber, 10);
Expand All @@ -90,7 +90,7 @@ try {
} else {
assert(
/^[123456]$/.test(headerLevel),
`invalid input provided for "headerLevel": expected an integer between 1 and 6 inclusive, or "false"`
`invalid input provided for "headerLevel": expected an integer between 1 and 6 inclusive, or "false"`,
);

commitTitlePrefix = "#".repeat(parseInt(headerLevel, 10)) + " ";
Expand All @@ -109,7 +109,7 @@ try {
if (typeof issueNumber == "number")
await octokit.addIssueComment(
await octokit.getIssueOrDiscussionId(owner, name, issueNumber, "issue"),
body
body,
);

if (typeof discussionNumber == "number")
Expand All @@ -118,9 +118,9 @@ try {
owner,
name,
discussionNumber,
"discussion"
"discussion",
),
body
body,
);
}
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getOctokit(
auth = core.getInput("token", {
required: false,
trimWhitespace: true,
})
}),
) {
const methods = {
getIssueOrDiscussionId: (() => {
Expand All @@ -44,7 +44,7 @@ export function getOctokit(
}
}
`,
{ owner: repoOwner, name: repoName, number }
{ owner: repoOwner, name: repoName, number },
)
).repository[which].id);
};
Expand All @@ -67,7 +67,7 @@ export function getOctokit(
}
}
`,
{ input: { subjectId: issueId, body: comment } }
{ input: { subjectId: issueId, body: comment } },
)
).addComment.commentEdge.node.url;
},
Expand All @@ -89,7 +89,7 @@ export function getOctokit(
body: comment,
discussionId,
},
}
},
)
).addDiscussionComment.comment.url;
},
Expand Down
12 changes: 6 additions & 6 deletions src/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ test.serial(
repoOwner,
repoName,
issueNum,
"issue"
"issue",
);

t.log("id:", id);
t.is(typeof id, "string");
t.true(id.length > 0, "id length is 0!");
issueId = id;
}
},
);

test.serial(
Expand All @@ -39,19 +39,19 @@ test.serial(
repoOwner,
repoName,
discussionNum,
"discussion"
"discussion",
);

t.log("id:", id);
t.is(typeof id, "string");
t.true(id.length > 0, "id length is 0!");
discussionId = id;
}
},
);

test.serial("addIssueComment()", async (t) => {
const expectedUrl = new URL(
`https://github.com/${repoOwner}/${repoName}/issues/${issueNum}#issuecomment-`
`https://github.com/${repoOwner}/${repoName}/issues/${issueNum}#issuecomment-`,
);

let url = await octokit.addIssueComment(issueId, "test comment");
Expand All @@ -64,7 +64,7 @@ test.serial("addIssueComment()", async (t) => {

test.serial("addDiscussionComment()", async (t) => {
const expectedUrl = new URL(
`https://github.com/${repoOwner}/${repoName}/discussions/${discussionNum}#discussioncomment-`
`https://github.com/${repoOwner}/${repoName}/discussions/${discussionNum}#discussioncomment-`,
);

let url = await octokit.addDiscussionComment(discussionId, "test comment");
Expand Down
10 changes: 5 additions & 5 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ test.before(async (t) => {
GITHUB_EVENT_NAME: ctx.event,
...this.resolveInputs(ctx.inputs),
},
}
},
);
}
}

Harness.actionYAML = yaml.load(await readFile("action.yml", "utf8"));

tmpDir = await mkdtemp(
os.tmpdir().replace(new RegExp(`${path.sep}+$`, "u"), "") + path.sep + "bc"
os.tmpdir().replace(new RegExp(`${path.sep}+$`, "u"), "") + path.sep + "bc",
);

t.context.defaultHarness = new Harness({
Expand All @@ -94,7 +94,7 @@ test.after.always("cleanup: remove temp dir", async (t) => {

test("smoke test: encounters no errors and exits zero/cleanly", async (t) => {
await t.notThrowsAsync(
t.context.defaultHarness.run({ inputs: { issueNumber: testIssue } })
t.context.defaultHarness.run({ inputs: { issueNumber: testIssue } }),
);
});

Expand All @@ -108,13 +108,13 @@ test(`if event != "push": don't error but quickly bail/exit 0 and print warning`
t.context.defaultHarness.run({
event: "release",
payload: { action: "created" },
})
}),
);

const result = await promise;

t.regex(
result.stdout,
/^\s*::\s*warning.*(?:title=|::)\s*unsupported\s*event/iu
/^\s*::\s*warning.*(?:title=|::)\s*unsupported\s*event/iu,
);
});

0 comments on commit aa3e244

Please sign in to comment.