diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index 026b190d..27affe79 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -167,14 +167,22 @@ describe('Tools tests', () => { }); it('checking addPhive', async () => { - let script: string = await tools.addPhive('1.2.3', 'linux'); + let script: string = await tools.addPhive('1.2.3', '7.4', 'linux'); expect(script).toContain( 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' ); - script = await tools.addPhive('latest', 'win32'); + script = await tools.addPhive('latest', '5.5', 'win32'); + expect(script).toContain('Phive is not supported on PHP 5.5'); + + script = await tools.addPhive('latest', '5.6', 'win32'); expect(script).toContain( - 'Add-Tool https://phar.io/releases/phive.phar phive' + 'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive' + ); + + script = await tools.addPhive('latest', '7.1', 'win32'); + expect(script).toContain( + 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive' ); }); diff --git a/dist/index.js b/dist/index.js index 90600d3f..a7a465a0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1908,9 +1908,20 @@ exports.getCodeceptionUri = getCodeceptionUri; * Helper function to get script to setup phive * * @param version + * @param php_version * @param os_version */ -async function addPhive(version, os_version) { +async function addPhive(version, php_version, os_version) { + switch (true) { + case /5\.[3-5]/.test(php_version): + return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + php_version, os_version); + case /5\.6|7\.0/.test(php_version): + version = version.replace('latest', '0.12.1'); + break; + case /7\.1/.test(php_version): + version = version.replace('latest', '0.13.5'); + break; + } switch (version) { case 'latest': return ((await utils.getCommand(os_version, 'tool')) + @@ -2208,7 +2219,7 @@ async function addTools(tools_csv, php_version, os_version) { script += await addPackage(tool, release, 'robmorgan/', os_version); break; case 'phive': - script += await addPhive(version, os_version); + script += await addPhive(version, php_version, os_version); break; case 'php-config': case 'phpize': diff --git a/src/tools.ts b/src/tools.ts index 24c3a2e0..724bd12b 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -157,12 +157,29 @@ export async function getCodeceptionUri( * Helper function to get script to setup phive * * @param version + * @param php_version * @param os_version */ export async function addPhive( version: string, + php_version: string, os_version: string ): Promise { + switch (true) { + case /5\.[3-5]/.test(php_version): + return await utils.addLog( + '$cross', + 'phive', + 'Phive is not supported on PHP ' + php_version, + os_version + ); + case /5\.6|7\.0/.test(php_version): + version = version.replace('latest', '0.12.1'); + break; + case /7\.1/.test(php_version): + version = version.replace('latest', '0.13.5'); + break; + } switch (version) { case 'latest': return ( @@ -539,7 +556,7 @@ export async function addTools( script += await addPackage(tool, release, 'robmorgan/', os_version); break; case 'phive': - script += await addPhive(version, os_version); + script += await addPhive(version, php_version, os_version); break; case 'php-config': case 'phpize':