Skip to content

Commit 2a597f6

Browse files
committed
Fix race condition
1 parent 2282b6a commit 2a597f6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/scripts/tools/add_tools.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Function Edit-ComposerConfig() {
2828
Set-ComposerAuth
2929
}
3030

31-
# Function to merge auth.json fragments.
32-
Function Get-MergedAuthJson {
31+
# Function to update auth.json.
32+
Function Update-AuthJson {
3333
[CmdletBinding()]
3434
param(
3535
[Parameter(Mandatory)][string[]] $ComposerAuth
@@ -58,7 +58,7 @@ Function Get-MergedAuthJson {
5858
}
5959
}
6060
}
61-
return $existing | ConvertTo-Json -Depth 5
61+
Set-Content -Path $composer_home\auth.json -Value ($existing | ConvertTo-Json -Depth 5)
6262
}
6363

6464
# Function to setup authentication in composer.
@@ -81,7 +81,7 @@ Function Set-ComposerAuth() {
8181
$composer_auth += '"github-oauth": {"github.com": "' + $env:GITHUB_TOKEN + '"}'
8282
}
8383
if($composer_auth.length) {
84-
Set-Content -Path $composer_home\auth.json -Value (Get-MergedAuthJson $composer_auth)
84+
Update-AuthJson $composer_auth
8585
}
8686
}
8787

src/scripts/tools/add_tools.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ configure_composer() {
4747
}
4848

4949
# Function to merge auth.json fragments.
50-
get_merged_auth_json() {
50+
update_auth_json() {
5151
local auth_file="$composer_home/auth.json"
5252
local merged
5353
[[ -f "$auth_file" ]] && merged=$(<"$auth_file") || merged='{}'
@@ -62,7 +62,7 @@ get_merged_auth_json() {
6262
end
6363
')
6464
done
65-
printf '%s' "$merged"
65+
printf '%s' "$merged" > "$composer_home/auth.json"
6666
}
6767

6868
# Function to setup authentication in composer.
@@ -82,7 +82,7 @@ set_composer_auth() {
8282
composer_auth+=( '"github-oauth": {"github.com": "'"${GITHUB_TOKEN:-$COMPOSER_TOKEN}"'"}' )
8383
fi
8484
if ((${#composer_auth[@]})); then
85-
get_merged_auth_json "${composer_auth[@]}" | tee "$composer_home/auth.json" >/dev/null
85+
update_auth_json "${composer_auth[@]}"
8686
fi
8787
}
8888

0 commit comments

Comments
 (0)