Skip to content

Commit ae4451d

Browse files
Merge pull request #35 from PowershellFrameworkCollective/development
updated install script
2 parents 7556548 + 4b3bc16 commit ae4451d

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

PSModuleDevelopment/tests/general/PSScriptAnalyzer.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Describe 'Invoking PSScriptAnalyzer against commandbase' {
2020
foreach ($file in $commandFiles)
2121
{
2222
Context "Analyzing $($file.BaseName)" {
23-
$analysis = Invoke-ScriptAnalyzer -Path $file.FullName
23+
$analysis = Invoke-ScriptAnalyzer -Path $file.FullName -ExcludeRule PSAvoidTrailingWhitespace
2424

2525
forEach ($rule in $scriptAnalyzerRules)
2626
{
@@ -29,11 +29,11 @@ Describe 'Invoking PSScriptAnalyzer against commandbase' {
2929
{
3030
$analysis | Where-Object RuleName -EQ $rule -outvariable failures | ForEach-Object { $list.Add($_) }
3131

32-
1 | Should Be 0
32+
1 | Should -Be 0
3333
}
3434
else
3535
{
36-
0 | Should Be 0
36+
0 | Should -Be 0
3737
}
3838
}
3939
}

install.ps1

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
1717
.PARAMETER UserMode
1818
The downloaded module will be moved to the user profile, rather than program files.
19+
20+
.PARAMETER Scope
21+
By default, the downloaded module will be moved to program files.
22+
Setting this to 'CurrentUser' installs to the userprofile of the current user.
1923
2024
.PARAMETER Force
2125
The install script will overwrite an existing module.
@@ -28,6 +32,10 @@ Param (
2832
[switch]
2933
$UserMode,
3034

35+
[ValidateSet('AllUsers', 'CurrentUser')]
36+
[string]
37+
$Scope = "AllUsers",
38+
3139
[switch]
3240
$Force
3341
)
@@ -43,6 +51,15 @@ $BaseUrl = "https://github.com/PowershellFrameworkCollective/PSModuleDevelopment
4351
$SubFolder = "PSModuleDevelopment"
4452
#endregion Configuration for cloning script
4553

54+
#region Parameter Calculation
55+
$doUserMode = $false
56+
if ($UserMode) { $doUserMode = $true }
57+
if ($install_CurrentUser) { $doUserMode = $true }
58+
if ($Scope -eq 'CurrentUser') { $doUserMode = $true }
59+
60+
if ($install_Branch) { $Branch = $install_Branch }
61+
#endregion Parameter Calculation
62+
4663
#region Utility Functions
4764
function Compress-Archive
4865
{
@@ -2349,7 +2366,7 @@ function Write-LocalMessage
23492366
[string]$Message
23502367
)
23512368

2352-
if (Test-Path function:Write-PSFMessage) { Write-PSFMessage -Level Important -Message $Message }
2369+
if (([System.Management.Automation.PSTypeName]'PSFramework.Commands.WritePSFMessageCommand').Type) { Write-PSFMessage -Level Important -Message $Message -FunctionName "Install-$ModuleName" }
23532370
else { Write-Host $Message }
23542371
}
23552372
#endregion Utility Functions
@@ -2378,7 +2395,7 @@ try
23782395

23792396
# Determine output path
23802397
$path = "$($env:ProgramFiles)\WindowsPowerShell\Modules\$($ModuleName)"
2381-
if ($UserMode) { $path = "$($HOME)\Documents\WindowsPowerShell\Modules\$($ModuleName)" }
2398+
if ($doUserMode) { $path = "$(Split-Path $profile.CurrentUserAllHosts)\Modules\$($ModuleName)" }
23822399
if ($PSVersionTable.PSVersion.Major -ge 5) { $path += "\$moduleVersion" }
23832400

23842401
if ((Test-Path $path) -and (-not $Force))
@@ -2411,4 +2428,4 @@ catch
24112428
Remove-Item -Path "$($env:TEMP)\$($ModuleName).zip" -Force
24122429

24132430
throw
2414-
}
2431+
}

0 commit comments

Comments
 (0)