From 71c631cffbd2369754f9a44df81205380a6c6be5 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Mon, 25 Nov 2019 14:03:28 +0100 Subject: [PATCH] Fix installing xdebug with PHP 7.4 on Windows --- __tests__/extensions.test.ts | 2 +- src/extensions.ts | 9 ++++++++- src/scripts/win32.ps1 | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 8c02e9b1..08b9fe44 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -10,7 +10,7 @@ describe('Extension tests', () => { expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension pcov'); win32 = await extensions.addExtension('xdebug, pcov', '7.4', 'win32'); - expect(win32).toContain('Add-Extension pcov'); + expect(win32).toContain('Add-Extension xdebug beta'); win32 = await extensions.addExtension( 'does_not_exist', diff --git a/src/extensions.ts b/src/extensions.ts index 7d52b39d..f9efb6fe 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -50,7 +50,14 @@ export async function addExtensionWindows( let script = '\n'; await utils.asyncForEach(extensions, async function(extension: string) { // add script to enable extension is already installed along with php - script += '\nAdd-Extension ' + extension; + let minimum_stability = 'stable'; + switch (version + extension.toLowerCase()) { + case '7.4xdebug': + minimum_stability = 'beta'; + break; + } + script += ` +Add-Extension ${extension} ${minimum_stability}`; }); return script; } diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 7812e175..97a95f29 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -59,7 +59,7 @@ Add-Log $tick "PHP" $status Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir Add-Log $tick "Composer" "Installed" -Function Add-Extension($extension) { +Function Add-Extension($extension, $mininum_stability) { try { $extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension } if ($null -ne $extension_info) { @@ -77,7 +77,7 @@ Function Add-Extension($extension) { } } else { - Install-PhpExtension -Extension $extension -Path $php_dir + Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir Add-Log $tick $extension "Downloaded and enabled" } }