Skip to content

Commit 1522f31

Browse files
Refactor main.ps1 to streamline module import process and remove obsolete code
1 parent 72a8b14 commit 1522f31

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

scripts/main.ps1

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
#Requires -Modules GitHub
22

33
[CmdletBinding()]
4-
param(
5-
[Parameter()]
6-
[string] $Subject = $env:<ORG_NAME>_<REPO_NAME>_INPUT_subject
7-
)
8-
9-
begin {
10-
$scriptName = $MyInvocation.MyCommand.Name
11-
Write-Debug "[$scriptName] - Start"
12-
}
13-
14-
process {
15-
try {
16-
Write-Output "Hello, $Subject!"
17-
} catch {
18-
throw $_
19-
}
20-
}
21-
22-
end {
23-
Write-Debug "[$scriptName] - End"
4+
param()
5+
6+
$PSModulePath = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Select-Object -First 1
7+
Remove-Module -Name Helpers -Force -ErrorAction SilentlyContinue
8+
Get-Command -Module Helpers | ForEach-Object { Remove-Item -Path function:$_ -Force }
9+
Get-Item -Path "$PSModulePath/Helpers/999.0.0" | Remove-Item -Recurse -Force
10+
$modulePath = New-Item -Path "$PSModulePath/Helpers/999.0.0" -ItemType Directory -Force | Select-Object -ExpandProperty FullName
11+
Copy-Item -Path "$PSScriptRoot/Helpers/*" -Destination $modulePath -Recurse -Force
12+
LogGroup 'Importing module' {
13+
Import-Module -Name Helpers -Verbose
2414
}

0 commit comments

Comments
 (0)