Fix composer version for prestissimo & composer-prefetcher to v1

This commit is contained in:
Shivam Mathur
2020-10-25 00:55:01 +05:30
parent b108a66489
commit d0591e6d7c
3 changed files with 20 additions and 22 deletions

View File

@ -283,11 +283,15 @@ 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_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) {
case undefined:
switch (true) {
case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break;
default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');