Skip to content

Commit

Permalink
Add support for imagick for PHP 5.6+ on macOS using shivammathur/home…
Browse files Browse the repository at this point in the history
…brew-extensions
  • Loading branch information
shivammathur committed Oct 19, 2020
1 parent 0661130 commit 81c750c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
9 changes: 3 additions & 6 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ describe('Extension tests', () => {

it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension(
'Xdebug, pcov, grpc, igbinary, protobuf, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
'Xdebug, pcov, grpc, igbinary, imagick, protobuf, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3',
'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');
Expand Down Expand Up @@ -180,11 +181,7 @@ 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');
darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('pecl_install imagick');

Expand Down
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2845,8 +2845,9 @@ const utils = __importStar(__webpack_require__(163));
*
* @param extension_csv
* @param version
* @param pipe
*/
async function addExtensionDarwin(extension_csv, version) {
async function addExtensionDarwin(extension_csv, version, pipe) {
const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n';
let remove_script = '';
Expand Down Expand Up @@ -2885,19 +2886,19 @@ async function addExtensionDarwin(extension_csv, version) {
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return;
// match 5.6xdebug to 8.9xdebug, 5.6igbinary to 8.9igbinary
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole
// 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.9pcov
case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_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):
// match 5.4imagick and 5.5imagick
case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe);
break;
// match sqlite
Expand Down Expand Up @@ -3094,7 +3095,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));
return script + (await addExtensionDarwin(extension_csv, version, pipe));
case 'linux':
return script + (await addExtensionLinux(extension_csv, version, pipe));
default:
Expand Down
16 changes: 10 additions & 6 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import * as utils from './utils';
*
* @param extension_csv
* @param version
* @param pipe
*/
export async function addExtensionDarwin(
extension_csv: string,
version: string
version: string,
pipe: string
): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv);
let add_script = '\n';
Expand Down Expand Up @@ -65,19 +67,21 @@ export async function addExtensionDarwin(
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return;
// match 5.6xdebug to 8.9xdebug, 5.6igbinary to 8.9igbinary
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole
// 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.9pcov
case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(
version_extension
):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_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):
// match 5.4imagick and 5.5imagick
case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins(
'brew install pkg-config imagemagick' + pipe,
'&& ' + command_prefix + 'imagick' + pipe
Expand Down Expand Up @@ -346,7 +350,7 @@ export async function addExtension(
case 'win32':
return script + (await addExtensionWindows(extension_csv, version));
case 'darwin':
return script + (await addExtensionDarwin(extension_csv, version));
return script + (await addExtensionDarwin(extension_csv, version, pipe));
case 'linux':
return script + (await addExtensionLinux(extension_csv, version, pipe));
default:
Expand Down

0 comments on commit 81c750c

Please sign in to comment.