mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-11-26 09:06:44 +07:00
Fix fallback to latest version in tools.ts
This commit is contained in:
@ -244,6 +244,19 @@ describe('Tools tests', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('checking getUrl handles undefined version without double slash', async () => {
|
||||||
|
const data = getData({
|
||||||
|
tool: 'cs2pr',
|
||||||
|
repository: 'staabm/annotate-pull-request-from-checkstyle',
|
||||||
|
domain: 'https://github.com'
|
||||||
|
});
|
||||||
|
data['extension'] = '';
|
||||||
|
delete data['version'];
|
||||||
|
expect(await tools.getUrl(data)).toBe(
|
||||||
|
'https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/cs2pr'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | version_prefix | url
|
version | version_prefix | url
|
||||||
${'latest'} | ${''} | ${'https://example.com/tool.phar'}
|
${'latest'} | ${''} | ${'https://example.com/tool.phar'}
|
||||||
|
|||||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -156,7 +156,7 @@ export async function filterList(tools_list: string[]): Promise<string[]> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function getUrl(data: RS): Promise<string> {
|
export async function getUrl(data: RS): Promise<string> {
|
||||||
if (data['version'] === 'latest') {
|
if ((data['version'] ?? 'latest') === 'latest') {
|
||||||
return [
|
return [
|
||||||
data['domain'],
|
data['domain'],
|
||||||
data['repository'],
|
data['repository'],
|
||||||
@ -578,7 +578,6 @@ export async function addTools(
|
|||||||
break;
|
break;
|
||||||
case 'phar' === data['type']:
|
case 'phar' === data['type']:
|
||||||
data['url'] = await getUrl(data);
|
data['url'] = await getUrl(data);
|
||||||
console.log(data['url']);
|
|
||||||
script += await addArchive(data);
|
script += await addArchive(data);
|
||||||
break;
|
break;
|
||||||
case 'composer' === data['type']:
|
case 'composer' === data['type']:
|
||||||
|
|||||||
Reference in New Issue
Block a user