Skip to content

Commit 614bcb2

Browse files
committed
Update
1 parent 85838ec commit 614bcb2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

Chocolatey-Package-Updater.ps1

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ $packageInfo = @{
6767
PackageName = "fxsound"
6868
FileUrl = 'https://download.fxsound.com/fxsoundlatest' # URL to download the file from
6969
FileDestinationPath = '.\tools\fxsound_setup.exe' # Path to move/rename the temporary file to (if EXE is distributed in package
70-
EnvFilePath = '..\.env' # Path to the .env file containing environment variables
70+
EnvFilePath = '..\.env' # Path to the .env file containing environment variables
7171
}
7272
7373
# Call the UpdateChocolateyPackage function and pass the hash table
7474
UpdateChocolateyPackage @packageInfo
7575
7676
.EXAMPLE
7777
To update a Chocolatey package, run the following command:
78-
UpdateChocolateyPackage -PackageName "fxsound" -FileUrl "https://download.fxsound.com/fxsoundlatest" -Alert $true
78+
UpdateChocolateyPackage -PackageName "fxsound" -FileUrl "https://download.fxsound.com/fxsoundlatest" -Alert $true -EnvFilePath "..\.env"
7979
8080
.EXAMPLE
8181
To update a Chocolatey package with additional parameters, run the following command:
82-
UpdateChocolateyPackage -PackageName "fxsound" -FileUrl "https://download.fxsound.com/fxsoundlatest" -FileDownloadTempPath ".\fxsound_setup_temp.exe" -FileDestinationPath ".\tools\fxsound_setup.exe" -NuspecPath ".\fxsound.nuspec" -InstallScriptPath ".\tools\ChocolateyInstall.ps1" -VerificationPath ".\tools\VERIFICATION.txt" -Alert $true
82+
UpdateChocolateyPackage -PackageName "fxsound" -FileUrl "https://download.fxsound.com/fxsoundlatest" -FileDownloadTempPath ".\fxsound_setup_temp.exe" -FileDestinationPath ".\tools\fxsound_setup.exe" -NuspecPath ".\fxsound.nuspec" -InstallScriptPath ".\tools\ChocolateyInstall.ps1" -VerificationPath ".\tools\VERIFICATION.txt" -Alert $true -EnvFilePath "..\.env"
8383
8484
.NOTES
8585
- Version: 0.1.0
@@ -307,13 +307,13 @@ function SendEmailMailjet {
307307
$url = "https://api.mailjet.com/v3.1/send"
308308

309309
$body = @{
310-
Messages = @(
310+
Messages = @(
311311
@{
312-
From = @{
312+
From = @{
313313
Email = $FromEmail
314314
Name = $FromName
315315
}
316-
To = @(
316+
To = @(
317317
@{
318318
Email = $ToEmail
319319
Name = $ToName
@@ -1046,9 +1046,13 @@ function UpdateChocolateyPackage {
10461046
choco push $filename
10471047
}
10481048

1049+
# Determine the push status
1050+
$pushStatus = if ($AutoPush) { "Pushed: TRUE" } else { "Pushed: FALSE" }
1051+
10491052
# Send an alert if enabled
10501053
Write-Debug "Sending alert..."
1051-
SendAlert -Subject "$PackageName Package Updated" -Message "$PackageName has been updated to version $ProductVersion." -Alert $Alert -Package $PackageName -EnvFilePath $EnvFilePath
1054+
$alertMessage = "$PackageName has been updated to version $ProductVersion.`n$pushStatus"
1055+
SendAlert -Subject "$PackageName Package Updated" -Message $alertMessage -Alert $Alert -EnvFilePath $EnvFilePath
10521056

10531057
# If the destination path is specified, move the downloaded file to the specified destination
10541058
if ($FileDestinationPath) {
@@ -1079,12 +1083,12 @@ function UpdateChocolateyPackage {
10791083

10801084
# Send an alert if enabled
10811085
Write-Debug "Sending package error alert..."
1082-
SendAlert -Subject "$PackageName Package Error" -Message "$PackageName detected an invalid version format. Please check the update script and files." -Alert $Alert -Package $PackageName -EnvFilePath $EnvFilePath
1086+
SendAlert -Subject "$PackageName Package Error" -Message "$PackageName detected an invalid version format. Please check the update script and files." -Alert $Alert -EnvFilePath $EnvFilePath
10831087
}
10841088
} catch {
10851089
# Send an alert if enabled
10861090
Write-Debug "Sending package error alert..."
1087-
SendAlert -Subject "$PackageName Package Error" -Message "$PackageName had an error when checking for updates. Please check the update script and files.`n`nError: $_" -Alert $Alert -Package $PackageName -EnvFilePath $EnvFilePath
1091+
SendAlert -Subject "$PackageName Package Error" -Message "$PackageName had an error when checking for updates. Please check the update script and files.`n`nError: $_" -Alert $Alert -EnvFilePath $EnvFilePath
10881092

10891093
# Write the error to the console
10901094
Write-Warning "An error occurred: $_"

0 commit comments

Comments
 (0)