mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Adjust filtered composer version
This commit is contained in:
parent
48f537d6d0
commit
5c4074b01a
@ -240,9 +240,17 @@ describe('Tools tests', () => {
|
||||
'a',
|
||||
'b'
|
||||
]);
|
||||
expect(await tools.addComposer(['a', 'b', 'composer:1.2'])).toStrictEqual([
|
||||
'composer',
|
||||
'a',
|
||||
'b'
|
||||
]);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
|
||||
).toStrictEqual(['composer', 'a', 'b']);
|
||||
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
|
||||
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:snapshot'])
|
||||
).toStrictEqual(['composer:snapshot', 'a', 'b']);
|
||||
@ -324,7 +332,7 @@ describe('Tools tests', () => {
|
||||
const tools_list: string[] = await tools.getCleanedToolsList(
|
||||
'tool, composer:1.2.3, robmorgan/phinx'
|
||||
);
|
||||
expect(tools_list).toStrictEqual(['composer', 'tool', 'phinx']);
|
||||
expect(tools_list).toStrictEqual(['composer:1.2.3', 'tool', 'phinx']);
|
||||
});
|
||||
|
||||
it('checking addArchive', async () => {
|
||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1894,7 +1894,7 @@ exports.getSymfonyUri = getSymfonyUri;
|
||||
*/
|
||||
async function addComposer(tools_list) {
|
||||
const regex_any = /^composer($|:.*)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
|
||||
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||
const matches = tools_list.filter(tool => regex_valid.test(tool));
|
||||
let composer = 'composer';
|
||||
@ -1906,7 +1906,7 @@ async function addComposer(tools_list) {
|
||||
case matches[0] == undefined:
|
||||
break;
|
||||
default:
|
||||
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
||||
composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
|
||||
break;
|
||||
}
|
||||
tools_list.unshift(composer);
|
||||
|
@ -282,7 +282,7 @@ export async function getSymfonyUri(
|
||||
*/
|
||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
const regex_any = /^composer($|:.*)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
|
||||
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
|
||||
let composer = 'composer';
|
||||
@ -294,7 +294,7 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
case matches[0] == undefined:
|
||||
break;
|
||||
default:
|
||||
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
||||
composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
|
||||
break;
|
||||
}
|
||||
tools_list.unshift(composer);
|
||||
|
Loading…
Reference in New Issue
Block a user