From a2b261d79ab105d91834001cc08c7c80c5580ef5 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Wed, 25 Mar 2020 07:44:38 +0530 Subject: [PATCH] Add support to configure GitHub OAuth token in composer --- src/scripts/darwin.sh | 3 +++ src/scripts/linux.sh | 3 +++ src/scripts/win32.ps1 | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 71676961..09145ece 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -108,6 +108,9 @@ add_tool() { sudo chmod a+x "$tool_path" if [ "$tool" = "composer" ]; then composer -q global config process-timeout 0 + if [ -n "$COMPOSER_TOKEN" ]; then + composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" + fi 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 diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 7a5ab52f..c2203a98 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -181,6 +181,9 @@ add_tool() { sudo chmod a+x "$tool_path" if [ "$tool" = "composer" ]; then composer -q global config process-timeout 0 + if [ -n "$COMPOSER_TOKEN" ]; then + composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" + fi elif [ "$tool" = "cs2pr" ]; then sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" elif [ "$tool" = "phive" ]; then diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index fc42ce08..18360e0f 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -136,6 +136,9 @@ Function Add-Tool() { (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr } elseif($tool -eq "composer") { composer -q global config process-timeout 0 + if (Test-Path env:COMPOSER_TOKEN) { + composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN + } } elseif($tool -eq "wp-cli") { Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat }