Accept PECL default parameters

This commit is contained in:
Shivam Mathur 2020-08-03 14:24:54 +05:30
parent 8876ac788f
commit 818ca89f55
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
5 changed files with 26 additions and 14 deletions

View File

@ -95,7 +95,7 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension grpc'); expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension swoole'); 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'); expect(darwin).toContain('add_unstable_extension ast beta extension');
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
@ -105,7 +105,7 @@ describe('Extension tests', () => {
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3'); expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); 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'); darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('add_brew_extension pcov'); expect(darwin).toContain('add_brew_extension pcov');
@ -120,18 +120,18 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension xdebug');
darwin = await extensions.addExtension('redis', '5.6', 'darwin'); 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'); 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'); darwin = await extensions.addExtension('imagick', '5.6', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick'); 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'); darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick'); 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( darwin = await extensions.addExtension(
'does_not_exist', 'does_not_exist',

2
dist/index.js vendored
View File

@ -3543,7 +3543,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
const version_extension = version + extension; const version_extension = version + extension;
const [extension_name, stability] = extension.split('-'); const [extension_name, stability] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(extension_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'sudo pecl install -f '; const command_prefix = 'pecl_install ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match pre-release versions // match pre-release versions

View File

@ -40,7 +40,7 @@ export async function addExtensionDarwin(
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [extension_name, stability]: string[] = extension.split('-'); const [extension_name, stability]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(extension_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'sudo pecl install -f '; const command_prefix = 'pecl_install ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match pre-release versions // match pre-release versions

View File

@ -34,6 +34,12 @@ check_extension() {
fi 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 # Fuction to get the PECL version
get_pecl_version() { get_pecl_version() {
extension=$1 extension=$1
@ -64,7 +70,7 @@ add_pecl_extension() {
else else
remove_extension "$extension" 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" && check_extension "$extension" &&
add_log "$tick" "$extension" "Installed and enabled" add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" ) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
@ -139,12 +145,12 @@ add_tool() {
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
configure_composer "$tool_path" configure_composer "$tool_path"
elif [ "$tool" = "phan" ]; then elif [ "$tool" = "phan" ]; then
add_extension fileinfo "sudo pecl install -f fileinfo" extension >/dev/null 2>&1 add_extension fileinfo "pecl_install fileinfo" extension >/dev/null 2>&1
add_extension ast "sudo pecl install -f ast" extension >/dev/null 2>&1 add_extension ast "pecl_install ast" extension >/dev/null 2>&1
elif [ "$tool" = "phive" ]; then elif [ "$tool" = "phive" ]; then
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1 add_extension curl "pecl_install curl" extension >/dev/null 2>&1
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1 add_extension mbstring "pecl_install mbstring" extension >/dev/null 2>&1
add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1 add_extension xml "pecl_install xml" extension >/dev/null 2>&1
elif [ "$tool" = "cs2pr" ]; then elif [ "$tool" = "cs2pr" ]; then
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" 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" tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"

View File

@ -59,6 +59,12 @@ get_pecl_version() {
echo "$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 # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 extension=$1