mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-01-23 09:07:52 +07:00
Update to Node 24
Update fetch.ts to use native fetch() API Use immutable sort in tools.ts
This commit is contained in:
13
src/tools.ts
13
src/tools.ts
@@ -46,14 +46,14 @@ export async function getSemverVersion(data: RS): Promise<string> {
|
||||
fixedToOriginal.set(f, t);
|
||||
return f;
|
||||
});
|
||||
fixed.sort((a, b) => {
|
||||
const sorted = fixed.toSorted((a, b) => {
|
||||
try {
|
||||
return cv.compareVersions(b, a);
|
||||
} catch {
|
||||
return b.localeCompare(a, 'en', {numeric: true, sensitivity: 'base'});
|
||||
}
|
||||
});
|
||||
return fixedToOriginal.get(fixed[0]) ?? fixed[0];
|
||||
return fixedToOriginal.get(sorted[0]) ?? sorted[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +74,10 @@ export async function getLatestVersion(data: RS): Promise<string> {
|
||||
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
||||
].map(match => match[2]);
|
||||
|
||||
return (
|
||||
releases
|
||||
.sort((a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {numeric: true})
|
||||
)
|
||||
.pop() || 'latest'
|
||||
const sorted = releases.toSorted((a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {numeric: true})
|
||||
);
|
||||
return sorted.at(-1) || 'latest';
|
||||
}
|
||||
return 'latest';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user