Skip to content

Commit 4225032

Browse files
authored
Merge pull request #919 from redanthrax/Node22
Support for NodeJS 22.
2 parents 37a4f5d + def2da5 commit 4225032

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

src/core/func-core-tools.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function isCoreToolsVersionCompatible(coreToolsVersion: number, nodeVersi
4242
// Runtime support reference: https://docs.microsoft.com/azure/azure-functions/functions-versions?pivots=programming-language-javascript#languages
4343
switch (coreToolsVersion) {
4444
case 4:
45-
return nodeVersion >= 18 && nodeVersion <= 20;
45+
return nodeVersion >= 18 && nodeVersion <= 22;
4646
case 3:
4747
return nodeVersion >= 14 && nodeVersion <= 20;
4848
case 2:
@@ -54,7 +54,7 @@ export function isCoreToolsVersionCompatible(coreToolsVersion: number, nodeVersi
5454

5555
export function detectTargetCoreToolsVersion(nodeVersion: number): number {
5656
// Pick the highest version that is compatible with the specified Node version
57-
if (nodeVersion >= 18 && nodeVersion <= 20) return 4;
57+
if (nodeVersion >= 18 && nodeVersion <= 22) return 4;
5858
if (nodeVersion >= 14 && nodeVersion < 20) return 3;
5959
if (nodeVersion >= 10 && nodeVersion < 14) return 2;
6060

@@ -121,35 +121,35 @@ function getPlatform() {
121121

122122
export async function getLatestCoreToolsRelease(targetVersion: number): Promise<CoreToolsRelease> {
123123
try {
124-
const response = await fetch(RELEASES_FEED_URL);
125-
const feed = (await response.json()) as { releases: Record<string, Record<string, CoreToolsZipInfo[]>>; };
126-
const platform = getPlatform();
127-
128-
const matchingVersions = Object.keys(feed.releases)
129-
.reverse() // JSON has newest versions first; we want the latest first; potential improvement: sort by semver
130-
.filter(
131-
(version) =>
132-
version.match(/^\d+\.\d+\.\d+$/) && // only stable versions
133-
version.startsWith(`${targetVersion}.`), // only matching major versions
134-
);
135-
136-
for (const version of matchingVersions) {
124+
const response = await fetch(RELEASES_FEED_URL);
125+
const feed = (await response.json()) as { releases: Record<string, Record<string, CoreToolsZipInfo[]>> };
126+
const platform = getPlatform();
127+
128+
const matchingVersions = Object.keys(feed.releases)
129+
.reverse() // JSON has newest versions first; we want the latest first; potential improvement: sort by semver
130+
.filter(
131+
(version) =>
132+
version.match(/^\d+\.\d+\.\d+$/) && // only stable versions
133+
version.startsWith(`${targetVersion}.`), // only matching major versions
134+
);
135+
136+
for (const version of matchingVersions) {
137137
const matchingDistribution = feed.releases[version].coreTools?.find(
138-
(dist) =>
139-
dist.OS === platform && // Distribution for matching platform
140-
dist.size === "full", // exclude minified releases
141-
);
142-
if (matchingDistribution) {
143-
return {
144-
version,
145-
url: matchingDistribution.downloadLink,
146-
sha2: matchingDistribution.sha2,
147-
};
148-
}
149-
}
150-
151-
throw new Error(`Cannot find download package for ${platform}`);
152-
} catch (error: unknown) {
138+
(dist) =>
139+
dist.OS === platform && // Distribution for matching platform
140+
dist.size === "full", // exclude minified releases
141+
);
142+
if (matchingDistribution) {
143+
return {
144+
version,
145+
url: matchingDistribution.downloadLink,
146+
sha2: matchingDistribution.sha2,
147+
};
148+
}
149+
}
150+
151+
throw new Error(`Cannot find download package for ${platform}`);
152+
} catch (error: unknown) {
153153
throw new Error(`Error fetching Function Core Tools releases: ${(error as Error).message}`);
154154
}
155155
}

0 commit comments

Comments
 (0)