-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.release.ps1
54 lines (40 loc) · 1.29 KB
/
install.release.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<#
.SYNOPSIS
Install release module.
.DESCRIPTION
Install module from release directory.
.EXAMPLE
PS> ./install.release.ps1
Install module for the current user only.
.EXAMPLE
PS> ./import.release.ps1 -AllUsers
Install module for all the users on the system.
.LINK
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_modules
#>
[CmdletBinding()]
param (
[Parameter()]
[switch] $AllUsers
)
# Load settings
$Settings = & (Join-Path -Path $PSScriptRoot -ChildPath "settings.ps1")
# Check if release module exists
if (-not (Test-Path -Path $Settings.Release -PathType Container)) {
Write-Error -ErrorAction Stop -Message "Release module does not exist. Build it first."
}
# Define ModuleRoot depending on scope
$ModuleRoot = if ($AllUsers.IsPresent) {
"$env:PROGRAMFILES\PowerShell\Modules"
}
else {
"$HOME\Documents\PowerShell\Modules"
}
# Define destination directory
$Destination = "$ModuleRoot\{0}\{1}" -f $Settings.ModuleName, $Settings.ModuleVersion
# Remove destination directory if exists
if (Test-Path -Path $Destination -PathType Container) {
Remove-Item -Path $Destination -Recurse
}
# Copy release module files to destination directory
Copy-Item -Path $Settings.Release -Destination $Destination -Recurse