diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 50f72a05..f1b7fb51 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -136,7 +136,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('remove_extension intl'); expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension'); @@ -163,13 +163,13 @@ describe('Extension tests', () => { expect(darwin).toContain('add_brew_extension pcov'); darwin = await extensions.addExtension('xdebug', '5.3', 'darwin'); - expect(darwin).toContain('sudo pecl install -f xdebug-2.2.7'); + expect(darwin).toContain('pecl_install xdebug-2.2.7'); darwin = await extensions.addExtension('xdebug', '5.4', 'darwin'); - expect(darwin).toContain('sudo pecl install -f xdebug-2.4.1'); + expect(darwin).toContain('pecl_install xdebug-2.4.1'); darwin = await extensions.addExtension('xdebug', '5.5', 'darwin'); - expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5'); + expect(darwin).toContain('pecl_install xdebug-2.5.5'); darwin = await extensions.addExtension('xdebug', '5.6', 'darwin'); expect(darwin).toContain('add_brew_extension xdebug'); @@ -181,18 +181,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('blackfire', '7.3', 'darwin'); expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire'); diff --git a/dist/index.js b/dist/index.js index 94a19c95..fb12ece4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3629,7 +3629,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) { const version_extension = version + extension; const [ext_name, ext_version] = extension.split('-'); const ext_prefix = await utils.getExtensionPrefix(ext_name); - const command_prefix = 'sudo pecl install -f '; + const command_prefix = 'pecl_install '; let command = ''; switch (true) { // match :extension diff --git a/src/extensions.ts b/src/extensions.ts index b3cfe70c..dea57997 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -20,7 +20,7 @@ export async function addExtensionDarwin( const version_extension: string = version + extension; const [ext_name, ext_version]: string[] = extension.split('-'); const ext_prefix = await utils.getExtensionPrefix(ext_name); - const command_prefix = 'sudo pecl install -f '; + const command_prefix = 'pecl_install '; let command = ''; switch (true) { // match :extension diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 35f6ac6d..672b40fc 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -70,6 +70,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 install a specific version of PECL extension. add_pecl_extension() { extension=$1 @@ -87,7 +93,7 @@ add_pecl_extension() { else remove_extension "$extension" >/dev/null 2>&1 ( - sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && + pecl_install "$extension-$pecl_version" && check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled" ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" @@ -161,12 +167,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 134f0b2d..b414a478 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -91,6 +91,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 check if an extension is loaded. check_extension() { extension=$1 @@ -167,8 +173,7 @@ add_extension() { install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}" fi eval "$install_command" >/dev/null 2>&1 || - (update_lists && eval "$install_command" >/dev/null 2>&1) || - sudo pecl install -f "$extension" >/dev/null 2>&1 + (update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension" (check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" fi @@ -192,7 +197,7 @@ add_pecl_extension() { else delete_extension "$extension" ( - sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && + pecl_install "$extension-$pecl_version" && check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled" ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"