From 74cdfb97c1185e70c4589c1d841a5ac96e5d1f34 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 19 Oct 2020 14:31:41 +0530 Subject: [PATCH] Add support for imagick and igbinary on macOS using shivammathur/homebrew-extensions --- __tests__/extensions.test.ts | 12 +++--------- dist/index.js | 25 +++++++------------------ src/extensions.ts | 28 +++++++++------------------- 3 files changed, 19 insertions(+), 46 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 0b2134af..6bb00eb0 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -78,13 +78,15 @@ describe('Extension tests', () => { it('checking addExtensionOnDarwin', async () => { let darwin: string = await extensions.addExtension( - 'Xdebug, pcov, grpc, protobuf, swoole, sqlite, ast-beta', + 'Xdebug, pcov, grpc, igbinary, imagick, protobuf, swoole, sqlite, ast-beta', '7.2', 'darwin' ); expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension pcov'); expect(darwin).toContain('add_brew_extension grpc'); + expect(darwin).toContain('add_brew_extension igbinary'); + expect(darwin).toContain('add_brew_extension imagick'); expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension swoole'); expect(darwin).toContain('pecl_install sqlite3'); @@ -117,14 +119,6 @@ describe('Extension tests', () => { darwin = await extensions.addExtension('redis', '7.2', 'darwin'); expect(darwin).toContain('pecl_install redis'); - darwin = await extensions.addExtension('imagick', '5.6', 'darwin'); - expect(darwin).toContain('brew install pkg-config imagemagick'); - expect(darwin).toContain('pecl_install imagick'); - - darwin = await extensions.addExtension('imagick', '7.4', 'darwin'); - expect(darwin).toContain('brew install pkg-config imagemagick'); - expect(darwin).toContain('pecl_install imagick'); - darwin = await extensions.addExtension( 'does_not_exist', '7.2', diff --git a/dist/index.js b/dist/index.js index e62413db..1d7514bb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2698,9 +2698,8 @@ const utils = __importStar(__webpack_require__(163)); * * @param extension_csv * @param version - * @param pipe */ -async function addExtensionDarwin(extension_csv, version, pipe) { +async function addExtensionDarwin(extension_csv, version) { const extensions = await utils.extensionArray(extension_csv); let script = '\n'; await utils.asyncForEach(extensions, async function (extension) { @@ -2720,28 +2719,18 @@ async function addExtensionDarwin(extension_csv, version, pipe) { ' ' + ext_prefix; return; - // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole - // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf + // match 5.6xdebug to 8.0xdebug, 5.6igbinary to 8.0igbinary + // match 5.6grpc to 7.4grpc, 5.6imagick to 7.4imagick, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole // match 7.1pcov to 8.0pcov - case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): - case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): - case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): + case /(5\.6|7\.[0-4]|8\.0)(xdebug|igbinary)/.test(version_extension): + case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension): + case /(7\.[1-4]|8\.0])pcov/.test(version_extension): command = 'add_brew_extension ' + extension_name; break; // match 5.6redis case /5\.6redis/.test(version_extension): command = command_prefix + 'redis-2.2.8'; break; - // match imagick - case /^imagick$/.test(extension): - command = - 'brew install pkg-config imagemagick' + - pipe + - ' && ' + - command_prefix + - 'imagick' + - pipe; - break; // match sqlite case /^sqlite$/.test(extension): extension = 'sqlite3'; @@ -2914,7 +2903,7 @@ async function addExtension(extension_csv, version, os_version, no_step = false) case 'win32': return script + (await addExtensionWindows(extension_csv, version)); case 'darwin': - return script + (await addExtensionDarwin(extension_csv, version, pipe)); + return script + (await addExtensionDarwin(extension_csv, version)); case 'linux': return script + (await addExtensionLinux(extension_csv, version, pipe)); default: diff --git a/src/extensions.ts b/src/extensions.ts index 2857432e..960b1c56 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -6,12 +6,10 @@ import * as utils from './utils'; * * @param extension_csv * @param version - * @param pipe */ export async function addExtensionDarwin( extension_csv: string, - version: string, - pipe: string + version: string ): Promise { const extensions: Array = await utils.extensionArray(extension_csv); let script = '\n'; @@ -32,28 +30,20 @@ export async function addExtensionDarwin( ' ' + ext_prefix; return; - // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole - // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf + // match 5.6xdebug to 8.0xdebug, 5.6igbinary to 8.0igbinary + // match 5.6grpc to 7.4grpc, 5.6imagick to 7.4imagick, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole // match 7.1pcov to 8.0pcov - case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): - case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): - case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): + case /(5\.6|7\.[0-4]|8\.0)(xdebug|igbinary)/.test(version_extension): + case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test( + version_extension + ): + case /(7\.[1-4]|8\.0])pcov/.test(version_extension): command = 'add_brew_extension ' + extension_name; break; // match 5.6redis case /5\.6redis/.test(version_extension): command = command_prefix + 'redis-2.2.8'; break; - // match imagick - case /^imagick$/.test(extension): - command = - 'brew install pkg-config imagemagick' + - pipe + - ' && ' + - command_prefix + - 'imagick' + - pipe; - break; // match sqlite case /^sqlite$/.test(extension): extension = 'sqlite3'; @@ -239,7 +229,7 @@ export async function addExtension( case 'win32': return script + (await addExtensionWindows(extension_csv, version)); case 'darwin': - return script + (await addExtensionDarwin(extension_csv, version, pipe)); + return script + (await addExtensionDarwin(extension_csv, version)); case 'linux': return script + (await addExtensionLinux(extension_csv, version, pipe)); default: