diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index bb31f942..07a00a18 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -95,7 +95,7 @@ describe('Extension tests', () => { expect(darwin).toContain('add_brew_extension grpc'); expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension swoole'); - expect(darwin).toContain('sudo pecl install -f sqlite3'); + expect(darwin).toContain('pecl_install sqlite3'); expect(darwin).toContain('add_unstable_extension ast beta extension'); darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); @@ -105,7 +105,7 @@ describe('Extension tests', () => { expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3'); darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); - expect(darwin).toContain('sudo pecl install -f pcov'); + expect(darwin).toContain('pecl_install pcov'); darwin = await extensions.addExtension('pcov', '7.2', 'darwin'); expect(darwin).toContain('add_brew_extension pcov'); @@ -120,18 +120,18 @@ describe('Extension tests', () => { expect(darwin).toContain('add_brew_extension xdebug'); darwin = await extensions.addExtension('redis', '5.6', 'darwin'); - expect(darwin).toContain('sudo pecl install -f redis-2.2.8'); + expect(darwin).toContain('pecl_install redis-2.2.8'); darwin = await extensions.addExtension('redis', '7.2', 'darwin'); - expect(darwin).toContain('sudo pecl install -f redis'); + 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('sudo pecl install -f imagick'); + 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('sudo pecl install -f imagick'); + expect(darwin).toContain('pecl_install imagick'); darwin = await extensions.addExtension( 'does_not_exist', diff --git a/dist/index.js b/dist/index.js index 8ae8d291..b1a39dca 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3543,7 +3543,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { const version_extension = version + extension; const [extension_name, stability] = extension.split('-'); const ext_prefix = await utils.getExtensionPrefix(extension_name); - const command_prefix = 'sudo pecl install -f '; + const command_prefix = 'pecl_install '; let command = ''; switch (true) { // match pre-release versions diff --git a/src/extensions.ts b/src/extensions.ts index 41145bec..82e25670 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -40,7 +40,7 @@ export async function addExtensionDarwin( const version_extension: string = version + extension; const [extension_name, stability]: string[] = extension.split('-'); const ext_prefix = await utils.getExtensionPrefix(extension_name); - const command_prefix = 'sudo pecl install -f '; + const command_prefix = 'pecl_install '; let command = ''; switch (true) { // match pre-release versions diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index fd7daa0d..3505fd9b 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -34,6 +34,12 @@ check_extension() { fi } +# Function to install PECL extensions and accept default options +pecl_install() { + local extension=$1 + yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1 +} + # Fuction to get the PECL version get_pecl_version() { extension=$1 @@ -64,7 +70,7 @@ add_pecl_extension() { else remove_extension "$extension" ( - sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && + pecl_install "$extension-$pecl_version" >/dev/null 2>&1 && check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled" ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" @@ -139,12 +145,12 @@ add_tool() { if [ "$tool" = "composer" ]; then configure_composer "$tool_path" elif [ "$tool" = "phan" ]; then - add_extension fileinfo "sudo pecl install -f fileinfo" extension >/dev/null 2>&1 - add_extension ast "sudo pecl install -f ast" extension >/dev/null 2>&1 + add_extension fileinfo "pecl_install fileinfo" extension >/dev/null 2>&1 + add_extension ast "pecl_install ast" extension >/dev/null 2>&1 elif [ "$tool" = "phive" ]; then - add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1 - add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1 - add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1 + add_extension curl "pecl_install curl" extension >/dev/null 2>&1 + add_extension mbstring "pecl_install mbstring" extension >/dev/null 2>&1 + add_extension xml "pecl_install xml" extension >/dev/null 2>&1 elif [ "$tool" = "cs2pr" ]; then sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path" diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index f3a8e108..3c023f8c 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -59,6 +59,12 @@ get_pecl_version() { echo "$pecl_version" } +# Function to install PECL extensions and accept default options +pecl_install() { + local extension=$1 + yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1 +} + # Function to test if extension is loaded check_extension() { extension=$1