Skip to content

Commit e14aee7

Browse files
authored
Merge pull request #77 from jwittner/dev/formatting
Apply VS Code Format Document
2 parents df0b7a6 + f8dbc9d commit e14aee7

File tree

7 files changed

+362
-438
lines changed

7 files changed

+362
-438
lines changed

UnitySetup/DSCResources/xUnitySetup/xUnitySetup.psm1

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
.Parameter Versions
66
The versions of Unity to test for.
77
#>
8-
function Get-TargetResource
9-
{
8+
function Get-TargetResource {
109
[CmdletBinding()]
1110
[OutputType([System.Collections.Hashtable])]
1211
param
@@ -22,16 +21,14 @@ function Get-TargetResource
2221
$setupInstances = Get-UnitySetupInstance | Where-Object { $splitVersions -contains $_.Version }
2322
$result = @{
2423
"Versions" = $setupInstances | Select-Object -ExpandProperty Version | Sort-Object -Unique
25-
"Ensure" = if($setupInstances.Count -gt 0) { 'Present'} else { 'Absent' }
24+
"Ensure" = if ($setupInstances.Count -gt 0) { 'Present'} else { 'Absent' }
2625
}
2726

2827
Write-Verbose "Found versions: $($result['Versions'])"
2928

30-
if( $setupInstances.Count -gt 0 )
31-
{
29+
if ( $setupInstances.Count -gt 0 ) {
3230
$components = $setupInstances[0].Components;
33-
for( $i = 1; $i -lt $setupInstances.Count; $i++)
34-
{
31+
for ( $i = 1; $i -lt $setupInstances.Count; $i++) {
3532
$components = $components -band $setupInstances[$i].Components;
3633
}
3734

@@ -57,53 +54,51 @@ function Get-TargetResource
5754
Only uninstalls whole versions of Unity. Ensuring components doesn't
5855
mean other components weren't previously installed and aren't still available.
5956
#>
60-
function Set-TargetResource
61-
{
57+
function Set-TargetResource {
6258
[CmdletBinding()]
6359
param
6460
(
6561
[parameter(Mandatory = $true)]
6662
[System.String]
6763
$Versions,
6864

69-
[ValidateSet("Present","Absent")]
65+
[ValidateSet("Present", "Absent")]
7066
[System.String]
7167
$Ensure = 'Present',
7268

7369
[System.String[]]
74-
$Components = @('All')
70+
$Components = @('All')
7571
)
7672

7773
Write-Verbose "Begin executing Set to Ensure $Versions with $Components are $Ensure"
7874

7975
[string[]]$splitVersions = $Versions -split ',' | ForEach-Object { $_.Trim() }
8076

81-
switch($Ensure) {
77+
switch ($Ensure) {
8278
'Present' {
83-
foreach($version in $splitVersions)
84-
{
79+
foreach ($version in $splitVersions) {
8580
$findArgs = @{
86-
'Version' = $version
81+
'Version' = $version
8782
'Components' = New-UnitySetupComponent -Components $Components
8883
}
8984

9085
$installArgs = @{ 'Cache' = "$env:TEMP\.unitysetup" }
9186

9287
$setupInstances = Get-UnitySetupInstance | Select-UnitySetupInstance -Version $version
93-
if($setupInstances.Count -gt 0) {
88+
if ($setupInstances.Count -gt 0) {
9489
$findArgs["Components"] = ($findArgs.Components -band (-bnot ($setupInstances[0].Components -band $findArgs.Components)))
9590
$installArgs["Destination"] = $setupInstances[0].Path
9691
}
9792

9893
# No missing components for this version
99-
if( $findArgs.Components -eq 0 ) {
94+
if ( $findArgs.Components -eq 0 ) {
10095
Write-Verbose "All components of $version were installed"
10196
continue;
10297
}
10398

10499
Write-Verbose "Finding $($findArgs["Components"]) installers for $version"
105100
$installArgs["Installers"] = Find-UnitySetupInstaller @findArgs -WarningAction Stop
106-
if( $installArgs.Installers.Count -gt 0 ) {
101+
if ( $installArgs.Installers.Count -gt 0 ) {
107102
Write-Verbose "Starting install of $($installArgs.Installers.Count) components for $version"
108103
Install-UnitySetupInstance @installArgs
109104
Write-Verbose "Finished install of $($installArgs.Installers.Count) components for $version"
@@ -114,7 +109,7 @@ function Set-TargetResource
114109
$setupInstances = Get-UnitySetupInstance | Where-Object { $splitVersions -contains $_.Version }
115110
Write-Verbose "Found $($setupInstances.Count) instance(s) of $splitVersions"
116111

117-
if( $setupInstances.Count -gt 0 ) {
112+
if ( $setupInstances.Count -gt 0 ) {
118113
Write-Verbose "Starting uninstall of $($setupInstances.Count) versions of Unity"
119114
Uninstall-UnitySetupInstance -Instances $setupInstances
120115
Write-Verbose "Finished uninstall of $($setupInstances.Count) versions of Unity"
@@ -137,8 +132,7 @@ function Set-TargetResource
137132
.Notes
138133
This test is not strict. Versions and Components not described are not considered.
139134
#>
140-
function Test-TargetResource
141-
{
135+
function Test-TargetResource {
142136
[CmdletBinding()]
143137
[OutputType([System.Boolean])]
144138
param
@@ -147,7 +141,7 @@ function Test-TargetResource
147141
[System.String]
148142
$Versions,
149143

150-
[ValidateSet("Present","Absent")]
144+
[ValidateSet("Present", "Absent")]
151145
[System.String]
152146
$Ensure = 'Present',
153147

@@ -160,38 +154,35 @@ function Test-TargetResource
160154
[string[]]$splitVersions = $Versions -split ',' | ForEach-Object { $_.Trim() }
161155

162156
$result = $true
163-
switch( $Ensure )
164-
{
157+
switch ( $Ensure ) {
165158
'Present' {
166159
$setupComponents = New-UnitySetupComponent -Components $Components
167-
foreach($version in $splitVersions)
168-
{
160+
foreach ($version in $splitVersions) {
169161
Write-Verbose "Starting test for $version"
170162
$setupInstances = Get-UnitySetupInstance | Select-UnitySetupInstance -Version $version
171163
Write-Verbose "Found $($setupInstances.Count) instance(s) of $version"
172164

173-
if($setupInstances.Count -eq 0) {
165+
if ($setupInstances.Count -eq 0) {
174166
Write-Verbose "Found $version missing."
175167
$result = $false
176168
break
177169
}
178170

179171
$availableComponents = ($setupInstances[0].Components -band $setupComponents)
180-
if($availableComponents -ne $setupComponents){
172+
if ($availableComponents -ne $setupComponents) {
181173
$missingComponents = New-UnitySetupComponent ($setupComponents -bxor $availableComponents)
182174
Write-Verbose "Found $version missing $($missingComponents)"
183175
$result = $false
184176
break
185177
}
186178
}
187179
}
188-
'Absent' {
189-
foreach($version in $splitVersions)
190-
{
180+
'Absent' {
181+
foreach ($version in $splitVersions) {
191182
$setupInstances = Get-UnitySetupInstance | Select-UnitySetupInstance -Version $version
192183
Write-Verbose "Found $($setupInstances.Count) instance(s) of $version"
193184

194-
if($setupInstances.Count -gt 0) {
185+
if ($setupInstances.Count -gt 0) {
195186
Write-Verbose "Found $version installed."
196187
$result = $false
197188
break

UnitySetup/Examples/Sample_xUnitySetup.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Configuration Sample_xUnitySetup {
1212
$Ensure = 'Present',
1313

1414
[System.String[]]
15-
$Components = @('Setup','Linux','Metro','Mac','iOS')
15+
$Components = @('Setup', 'Linux', 'Metro', 'Mac', 'iOS')
1616
)
1717

1818
Import-DscResource -ModuleName UnitySetup
1919

2020
Node 'localhost' {
2121

2222
xUnitySetup Unity {
23-
Versions = $Versions
23+
Versions = $Versions
2424
Components = $Components
25-
Ensure = $Ensure
25+
Ensure = $Ensure
2626
}
2727
}
2828
}

UnitySetup/Examples/Sample_xUnitySetup_Install.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Configuration Sample_xUnitySetup_Install {
88
Node 'localhost' {
99

1010
xUnitySetup Unity {
11-
Versions = '2017.3.1f1,2018.1.0b9'
11+
Versions = '2017.3.1f1,2018.1.0b9'
1212
Components = 'Setup', 'Mac', 'Linux', 'Metro', 'iOS'
13-
Ensure = 'Present'
13+
Ensure = 'Present'
1414
}
1515
}
1616
}

UnitySetup/Examples/Sample_xUnitySetup_Uninstall.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Configuration Sample_xUnitySetup_Install {
99

1010
xUnitySetup Unity {
1111
Versions = '2017.3.1f1,2018.1.0b9'
12-
Ensure = 'Absent'
12+
Ensure = 'Absent'
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)