From 5003661a6318133639f337c5cbed81cec2d9fd1c Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Sun, 5 Sep 2021 23:53:33 -0600 Subject: [PATCH] refactor(wakeup): move exit to function, use constants - move graceful exit to function to DRY code - use constant for wol module name --- wakeup.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wakeup.ps1 b/wakeup.ps1 index 34543b1..4d1c464 100644 --- a/wakeup.ps1 +++ b/wakeup.ps1 @@ -32,8 +32,14 @@ function exitError($errMessage, $PSItem, $exitCode = 1) Exit $exitCode } -$wolModuleName = "wol-magicPacket" -$wolDatabase = "WOLDatabase.xml" +function exitGracefully() +{ + Write-Host -ForegroundColor Green "`r`nFinished.`r`n" + Exit 0 +} + +# constants +Set-Variable -Name wolModuleName -Value "wol-magicPacket" -Option Constant # exit on error if Send-MagicPacket module is not loaded if (!(Get-Module -Name $wolModuleName))