Skip to content

Commit ddc99fb

Browse files
authored
Version 1.1.0
Wrapped all the function bodies in '$Null=@()' to prevent extra return values.
2 parents 3b581d4 + 8879eb3 commit ddc99fb

10 files changed

Lines changed: 29 additions & 7 deletions

Functions/ConfigGettersAndSetters.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,32 @@ $script:defaultConfigPath = "$PSScriptRoot\..\Config\config.json"
55
$script:registryConfigPath = "HKLM:\SOFTWARE\PythonPowershellUtilities"
66

77
function Get-PythonUtilitiesConfigValue([string]$Key){
8+
$Null = @(
89
# Add registry keys if they haven't been added already, otherwise just return them
910
if (!(Test-Path $script:registryConfigPath)){
1011
New-Item -Path $script:registryConfigPath
1112
Set-PythonUtilitiesConfigValue -Key "PythonInstallRoot" -Value "C:\PythonInstallations"
1213
Set-PythonUtilitiesConfigValue -Key "VirtualEnvironmentRoot" -Value "C:\PythonVirtualEnvironments"
1314
}
1415
$entry = Get-ItemProperty $script:registryConfigPath -Name $Key
16+
)
1517
return $entry.$Key
1618
}
1719

1820
function Set-PythonUtilitiesConfigValue([string]$Key, [string]$Value){
19-
Set-ItemProperty -Path $script:registryConfigPath -Name $Key -Value $Value
21+
$Null = @(
22+
Set-ItemProperty -Path $script:registryConfigPath -Name $Key -Value $Value > $null
23+
)
2024
}
2125

2226
function Get-PythonInstallerCache(){
27+
$Null = @(
2328
$installRoot = Get-PythonInstallRoot
2429
$installerCache = "$installRoot\Installers"
2530
if (!(Test-Path $installerCache)){
26-
New-Item -ItemType Directory -Path $installerCache -Force | Out-Null
31+
New-Item -ItemType Directory -Path $installerCache -Force > $null
2732
}
33+
)
2834
return $installerCache
2935
}
3036

@@ -33,6 +39,7 @@ function Get-PythonInstallRoot(){
3339
}
3440

3541
function Set-PythonInstallRoot([string]$Path, [switch]$Force=$false){
42+
$Null = @(
3643
$installRoot = Get-PythonInstallRoot
3744
$installerCache = Get-PythonInstallerCache
3845
if (Test-Path -Path $installerCache){
@@ -57,15 +64,17 @@ function Set-PythonInstallRoot([string]$Path, [switch]$Force=$false){
5764
}
5865
}
5966
}
60-
New-Item -ItemType directory -Path "$Path\Installers" -Force | Out-Null
67+
New-Item -ItemType directory -Path "$Path\Installers" -Force > $null
6168
Set-PythonUtilitiesConfigValue -Key "PythonInstallRoot" -Value $Path
69+
)
6270
}
6371

6472
function Get-VirtualEnvironmentRoot(){
6573
return Get-PythonUtilitiesConfigValue -Key "VirtualEnvironmentRoot"
6674
}
6775

6876
function Set-VirtualEnvironmentRoot([string]$Path, [switch]$Force){
77+
$Null = @(
6978
if (!$Force){
7079
$venvRootPath = Get-VirtualEnvironmentRoot
7180
if (Test-Path $venvRootPath) {
@@ -79,4 +88,5 @@ function Set-VirtualEnvironmentRoot([string]$Path, [switch]$Force){
7988
}
8089
}
8190
Set-PythonUtilitiesConfigValue -Key "VirtualEnvironmentRoot" -Value $Path
91+
)
8292
}

Functions/Enter-PythonVirtualEnvironment.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. "$PSScriptRoot\ConfigGettersAndSetters.ps1"
22

33
function Enter-PythonVirtualEnvironment([string]$Name){
4+
$Null = @(
45
$virtualenvRoot = Get-VirtualEnvironmentRoot
56

67
#Find matching virtualenv
@@ -16,4 +17,5 @@ function Enter-PythonVirtualEnvironment([string]$Name){
1617
}
1718

1819
throw "Could not find a virtual environment in $virtualenvRoot whose name starts with $Name."
20+
)
1921
}

Functions/Get-InstalledPythonVersions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Get-InstalledPythonVersions(){
44
$installedVersions = @()
55

66
foreach ($pathObj in Get-ChildItem "$installerCache\python*"){
7-
$pathObj.Name -match $versionRegex | Out-Null
7+
$pathObj.Name -match $versionRegex > $null
88
$installedVersions += $Matches.version
99
}
1010

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
. "$PSScriptRoot\ConfigGettersAndSetters.ps1"
22

33
function Get-PythonVirtualEnvironments(){
4+
$Null = @(
45
$virtualenvRoot = Get-VirtualEnvironmentRoot
56
$virtualEnvironments = @()
67
foreach ($item in Get-ChildItem $virtualenvRoot -Directory) {
78
$virtualEnvironments += $item.Name
89
}
9-
10+
)
1011
return ,$virtualEnvironments
1112
}

Functions/Install-Python.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
. "$PSScriptRoot\Get-PythonInstallerUrl.ps1"
33

44
function Install-Python([string]$Version){
5+
$Null = @(
56
$installerCache = Get-PythonInstallerCache
67
$installerUrl = Get-PythonInstallerUrl -Version $Version
78
$installRoot = Get-PythonInstallRoot
@@ -31,4 +32,5 @@ function Install-Python([string]$Version){
3132
if (!($result.ExitCode -eq 0)) {
3233
throw "Python installation failed."
3334
}
35+
)
3436
}

Functions/New-PythonVirtualEnvironment.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. "$PSScriptRoot\ConfigGettersAndSetters.ps1"
22

33
function New-PythonVirtualEnvironment([string]$Version, [string]$Name){
4+
$Null = @(
45
$installRoot = Get-PythonInstallRoot
56
$virtualenvRoot = Get-VirtualEnvironmentRoot
67
$pythonEXEPath = "$installRoot\python$Version\python.exe"
@@ -19,4 +20,5 @@ function New-PythonVirtualEnvironment([string]$Version, [string]$Name){
1920
if (!($result.ExitCode -eq 0)) {
2021
throw "Error creating virtual environment."
2122
}
23+
)
2224
}

Functions/Remove-PythonVirtualEnvironment.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. "$PSScriptRoot\ConfigGettersAndSetters.ps1"
22

33
function Remove-PythonVirtualEnvironment([string]$Name, [switch]$YesToAll=$false){
4+
$Null = @(
45
$virtualenvRoot = Get-VirtualEnvironmentRoot
56

67
#Find matching virtualenv
@@ -18,4 +19,5 @@ function Remove-PythonVirtualEnvironment([string]$Name, [switch]$YesToAll=$false
1819
}
1920

2021
throw "Could not find a virtual environment in $virtualenvRoot whose name starts with $Name."
22+
)
2123
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
. "$PSScriptRoot\ConfigGettersAndSetters.ps1"
22

33
function Restore-PythonUtilitiesConfigDefaults([switch]$Force){
4+
$Null = @(
45
if ($Force){
56
Set-PythonInstallRoot -Path "C:\PythonInstallations\" -Force
67
Set-VirtualEnvironmentRoot -Path "C:\PythonVirtualEnvironments\" -Force
@@ -9,5 +10,5 @@ function Restore-PythonUtilitiesConfigDefaults([switch]$Force){
910
Set-PythonInstallRoot -Path "C:\PythonInstallations\"
1011
Set-VirtualEnvironmentRoot -Path "C:\PythonVirtualEnvironments\"
1112
}
12-
13+
)
1314
}

Functions/Uninstall-Python.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
function Uninstall-Python([string]$Version){
2+
$Null = @(
23
$installerCache = Get-PythonInstallerCache
34
$installName = "python$Version"
45
$installerEXEPath = "$installerCache\$installName-Installer.exe"
@@ -14,4 +15,5 @@ function Uninstall-Python([string]$Version){
1415
}
1516

1617
Remove-Item -Path $installerEXEPath
18+
)
1719
}

PythonPowershellUtilities.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PythonPowershellUtilities.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.2'
15+
ModuleVersion = '1.1.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

0 commit comments

Comments
 (0)