Skip to content

Commit

Permalink
chore: some from mapped Promises
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Feb 12, 2024
1 parent 4a98c4f commit c0e8bcb
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/actions/validate-issue/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/actions/validate-issue/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/actions/validate-issue/lib/nodeVersions.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions .github/actions/validate-issue/lib/nodeVersions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/actions/validate-issue/lib/nodeVersions.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .github/actions/validate-issue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { execSync } from "child_process";
import * as semver from "semver";
import { readFileSync } from "fs";
import * as path from "path";
import { isValidVersion } from "./nodeVersions";
import { isAnyVersionValid } from "./nodeVersions";

async function run() {
try {
Expand Down Expand Up @@ -138,7 +138,7 @@ async function run() {
valid = false;
}
if (nodeVersions.length > 0) {
if (!nodeVersions.some(await isValidVersion(new Date()))) {
if (!(await isAnyVersionValid(new Date())(nodeVersions))) {
const nodeVersionMessage = getFile(
"../messages/unsupported-node.md",
{
Expand Down
19 changes: 11 additions & 8 deletions .github/actions/validate-issue/src/nodeVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ type VersionInfo = {
end: Date;
};

export const isValidVersion = (currentDate: Date) => async (
version: string
export const isAnyVersionValid = (currentDate: Date) => async (
versions: string[]
): Promise<boolean> => {
const formattedVersion = `v${version}`;
const resp = (await ((
await fetch(
"https://raw.githubusercontent.com/nodejs/Release/main/schedule.json"
)
).json() as unknown)) as Record<string, VersionInfo>;
return (
formattedVersion in resp &&
currentDate >= new Date(resp[formattedVersion].start) &&
currentDate <= new Date(resp[formattedVersion].end)
);

return versions
.map((version) => `v${version}`)
.some(
(formattedVersion) =>
formattedVersion in resp &&
currentDate >= new Date(resp[formattedVersion].start) &&
currentDate <= new Date(resp[formattedVersion].end)
);
};

0 comments on commit c0e8bcb

Please sign in to comment.