From f3a1262ff685f3e2a2a546bffa4b3127ce50cdf2 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 16 Mar 2020 06:53:58 +0530 Subject: [PATCH] Fix db extensions --- __tests__/extensions.test.ts | 13 +++++++++++++ dist/index.js | 21 +++++++++++++++++---- src/extensions.ts | 21 +++++++++++++++++---- src/scripts/darwin.sh | 6 +++++- src/scripts/linux.sh | 7 ++++++- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index a935e75f..f43830f8 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -15,6 +15,19 @@ describe('Extension tests', () => { expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); + win32 = await extensions.addExtension('mysql', '7.4', 'win32'); + expect(win32).toContain('Add-Extension mysqli'); + expect(win32).toContain('Add-Extension mysqlnd'); + + win32 = await extensions.addExtension('mysql', '8.0', 'win32'); + expect(win32).toContain('Add-Extension mysqli'); + expect(win32).toContain('Add-Extension mysqlnd'); + + win32 = await extensions.addExtension('mysql', '5.5', 'win32'); + expect(win32).toContain('Add-Extension mysql'); + expect(win32).toContain('Add-Extension mysqli'); + expect(win32).toContain('Add-Extension mysqlnd'); + win32 = await extensions.addExtension( 'phalcon3, does_not_exist', '7.2', diff --git a/dist/index.js b/dist/index.js index 3023fe07..d180e338 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2611,7 +2611,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { command = command_prefix + 'redis-2.2.8' + pipe; break; // match imagick - case /imagick/.test(extension): + case /^imagick$/.test(extension): command = 'brew install pkg-config imagemagick' + pipe + @@ -2621,7 +2621,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { pipe; break; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; command = command_prefix + extension + pipe; break; @@ -2684,8 +2684,21 @@ async function addExtensionWindows(extension_csv, version) { script += '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; return; + // match 5.3mysql..5.6mysql + // match 5.3mysqli..5.6mysqli + // match 5.3mysqlnd..5.6mysqlnd + case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): + script += + '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; + break; + // match 7.0mysql..8.0mysql + // match 7.0mysqli..8.0mysqli + // match 7.0mysqlnd..8.0mysqlnd + case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): + script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; + break; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; script += '\nAdd-Extension ' + extension; break; @@ -2789,7 +2802,7 @@ async function addExtensionLinux(extension_csv, version, pipe) { script += '\nadd_pdo_extension ' + extension; return; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; command = command_prefix + version + '-' + extension + pipe; break; diff --git a/src/extensions.ts b/src/extensions.ts index 8e69ee40..d15411d8 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -76,7 +76,7 @@ export async function addExtensionDarwin( command = command_prefix + 'redis-2.2.8' + pipe; break; // match imagick - case /imagick/.test(extension): + case /^imagick$/.test(extension): command = 'brew install pkg-config imagemagick' + pipe + @@ -86,7 +86,7 @@ export async function addExtensionDarwin( pipe; break; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; command = command_prefix + extension + pipe; break; @@ -158,8 +158,21 @@ export async function addExtensionWindows( script += '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; return; + // match 5.3mysql..5.6mysql + // match 5.3mysqli..5.6mysqli + // match 5.3mysqlnd..5.6mysqlnd + case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): + script += + '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; + break; + // match 7.0mysql..8.0mysql + // match 7.0mysqli..8.0mysqli + // match 7.0mysqlnd..8.0mysqlnd + case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): + script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; + break; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; script += '\nAdd-Extension ' + extension; break; @@ -269,7 +282,7 @@ export async function addExtensionLinux( script += '\nadd_pdo_extension ' + extension; return; // match sqlite - case /sqlite/.test(extension): + case /^sqlite$/.test(extension): extension = 'sqlite3'; command = command_prefix + version + '-' + extension + pipe; break; diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 0ee7d0ee..71676961 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -27,7 +27,11 @@ remove_extension() { # Function to test if extension is loaded check_extension() { extension=$1 - php -m | grep -i -q -w "$extension" + if [ "$extension" != "mysql" ]; then + php -m | grep -i -q -w "$extension" + else + php -m | grep -i -q "$extension" + fi } # Fuction to get the PECL version diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index d70a28d2..ab53da54 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -56,7 +56,12 @@ get_pecl_version() { # Function to test if extension is loaded check_extension() { - php -m | grep -i -q -w "$1" + extension=$1 + if [ "$extension" != "mysql" ]; then + php -m | grep -i -q -w "$extension" + else + php -m | grep -i -q "$extension" + fi } # Function to delete extensions