From dc964051f81553d60f0fe53975fefc0ccf4be773 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Mon, 27 May 2024 13:23:55 -0700 Subject: [PATCH] Remove unnecessary function wrapper --- install.ps1 | 60 +++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/install.ps1 b/install.ps1 index a1069c4..158b146 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,40 +1,36 @@ -function Install-ArdisUtilities { - [OutputType([System.Void])] - [CmdletBinding()] - param( - [Parameter()] - [Switch]$Persist - ) +[OutputType([System.Void])] +[CmdletBinding()] +param( + [Parameter()] + [Switch]$Persist +) - begin { - # Create a temporary working folder - $tempFolder = Join-Path $Env:Temp $(New-Guid) - New-Item -Type Directory -Path $tempFolder | Out-Null - } +begin { + # Create a temporary working folder + $tempFolder = Join-Path $Env:Temp $(New-Guid) + New-Item -Type Directory -Path $tempFolder | Out-Null +} - process { - # Download and extract the repository from GitHub - $zipFile = Join-Path $tempFolder /ArdisUtilities.zip - Invoke-WebRequest 'https://github.com/ardislu/ArdisUtilities/archive/refs/heads/main.zip' -OutFile $zipFile - Expand-Archive $zipFile $tempFolder - $module = Join-Path $tempFolder 'ArdisUtilities-main/ArdisUtilities' +process { + # Download and extract the repository from GitHub + $zipFile = Join-Path $tempFolder /ArdisUtilities.zip + Invoke-WebRequest 'https://github.com/ardislu/ArdisUtilities/archive/refs/heads/main.zip' -OutFile $zipFile + Expand-Archive $zipFile $tempFolder + $module = Join-Path $tempFolder 'ArdisUtilities-main/ArdisUtilities' - # Import the module from the extraction - Import-Module $module + # Import the module from the extraction + Import-Module $module - if ($Persist) { - $destination = "$HOME/Documents/PowerShell/Modules" # Default path for persistent PowerShell modules - if (Test-Path -LiteralPath "$destination/ArdisUtilities") { - Remove-Item "$destination/ArdisUtilities" -Force -Recurse - } - Copy-Item -Path $module -Destination $destination -Recurse + if ($Persist) { + $destination = "$HOME/Documents/PowerShell/Modules" # Default path for persistent PowerShell modules + if (Test-Path -LiteralPath "$destination/ArdisUtilities") { + Remove-Item "$destination/ArdisUtilities" -Force -Recurse } - } - - clean { - # Clean up the temporary folder - Remove-Item $tempFolder -Force -Recurse + Copy-Item -Path $module -Destination $destination -Recurse } } -Install-ArdisUtilities @args +clean { + # Clean up the temporary folder + Remove-Item $tempFolder -Force -Recurse +} -- 2.47.3