Allow installing a specific Composer version

This commit is contained in:
Michele Locati 2020-10-30 11:15:26 +01:00
parent c8111b053c
commit f51d00d350
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
3 changed files with 19 additions and 0 deletions

View File

@ -267,6 +267,15 @@ describe('Tools tests', () => {
expect(await tools.getComposerUrl('2')).toContain(
'https://getcomposer.org/composer-2.phar'
);
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
);
expect(await tools.getComposerUrl('wrong')).toContain(
'https://getcomposer.org/composer-stable.phar'
);
});
it('checking getSymfonyUri', async () => {

4
dist/index.js vendored
View File

@ -2058,6 +2058,10 @@ async function getComposerUrl(version) {
case '2':
return (cache_url + 'https://getcomposer.org/composer-' + version + '.phar');
default:
if (/^\d+\.\d+\.\d+[\w-]*$/.test(version)) {
return (cache_url +
`https://github.com/composer/composer/releases/download/${version}/composer.phar`);
}
return cache_url + 'https://getcomposer.org/composer-stable.phar';
}
}

View File

@ -344,6 +344,12 @@ export async function getComposerUrl(version: string): Promise<string> {
cache_url + 'https://getcomposer.org/composer-' + version + '.phar'
);
default:
if (/^\d+\.\d+\.\d+[\w-]*$/.test(version)) {
return (
cache_url +
`https://github.com/composer/composer/releases/download/${version}/composer.phar`
);
}
return cache_url + 'https://getcomposer.org/composer-stable.phar';
}
}