Skip to content

Commit 0f63e8e

Browse files
committed
Auto formatting
1 parent 13d017c commit 0f63e8e

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

UnitySetup/UnitySetup.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
# Modules that must be imported into the global environment prior to importing this module
5656
RequiredModules = @(
57-
@{ModuleName = "powershell-yaml"; ModuleVersion = "0.3"; Guid = "6a75a662-7f53-425a-9777-ee61284407da"}
57+
@{ModuleName = "powershell-yaml"; ModuleVersion = "0.3"; Guid = "6a75a662-7f53-425a-9777-ee61284407da" }
5858
)
5959

6060
# Assemblies that must be loaded prior to importing this module

UnitySetup/UnitySetup.psm1

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ class UnityProjectInstance {
117117

118118
UnityProjectInstance([string]$path) {
119119
$versionFile = [io.path]::Combine($path, "ProjectSettings\ProjectVersion.txt")
120-
if (!(Test-Path $versionFile)) { throw "Path is not a Unity project: $path"}
120+
if (!(Test-Path $versionFile)) { throw "Path is not a Unity project: $path" }
121121

122122
$fileVersion = (Get-Content $versionFile -Raw | ConvertFrom-Yaml)['m_EditorVersion'];
123-
if (!$fileVersion) { throw "Project is missing a version in: $versionFile"}
123+
if (!$fileVersion) { throw "Project is missing a version in: $versionFile" }
124124

125125
$projectSettingsFile = [io.path]::Combine($path, "ProjectSettings\ProjectSettings.asset")
126-
if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset"}
126+
if (!(Test-Path $projectSettingsFile)) { throw "Project is missing ProjectSettings.asset" }
127127

128128
$prodName = ((Get-Content $projectSettingsFile -Raw | ConvertFrom-Yaml)['playerSettings'])['productName']
129-
if (!$prodName) { throw "ProjectSettings is missing productName"}
129+
if (!$prodName) { throw "ProjectSettings is missing productName" }
130130

131131
$this.Path = $path
132132
$this.Version = $fileVersion
@@ -144,7 +144,7 @@ class UnityVersion : System.IComparable {
144144

145145
[string] ToString() {
146146
$result = "$($this.Major).$($this.Minor).$($this.Revision)$($this.Release)$($this.Build)"
147-
if ( $this.Suffix ) { $result += "-$($this.Suffix)"}
147+
if ( $this.Suffix ) { $result += "-$($this.Suffix)" }
148148
return $result
149149
}
150150

@@ -166,7 +166,7 @@ class UnityVersion : System.IComparable {
166166

167167
[int] CompareTo([object]$obj) {
168168
if ($null -eq $obj) { return 1 }
169-
if ($obj -isnot [UnityVersion]) { throw "Object is not a UnityVersion"}
169+
if ($obj -isnot [UnityVersion]) { throw "Object is not a UnityVersion" }
170170

171171
return [UnityVersion]::Compare($this, $obj)
172172
}
@@ -245,7 +245,7 @@ function Get-OperatingSystem {
245245
function Get-UnityEditor {
246246
[CmdletBinding()]
247247
param(
248-
[ValidateScript( {Test-Path $_ -PathType Container} )]
248+
[ValidateScript( { Test-Path $_ -PathType Container } )]
249249
[Parameter(Mandatory = $false, ValueFromPipeline = $true, Position = 0, ParameterSetName = "Path")]
250250
[string[]]$Path = $PWD,
251251

@@ -426,27 +426,30 @@ function Find-UnitySetupInstaller {
426426
$searchPages += $patchPage
427427

428428
$webResult = Invoke-WebRequest $patchPage -UseBasicParsing
429-
$searchPages += $webResult.Links | Where-Object {
430-
$_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" -and $Matches[1] -gt 1
431-
} | ForEach-Object { "https://unity3d.com$($_.href)" }
429+
$searchPages += $webResult.Links |
430+
Where-Object { $_.href -match "\/unity\/qa\/patch-releases\?version=$($Version.Major)\.$($Version.Minor)&page=(\d+)" -and $Matches[1] -gt 1 } |
431+
ForEach-Object { "https://unity3d.com$($_.href)" }
432432
}
433433
}
434434

435435
foreach ($page in $searchPages) {
436436
try {
437437
$webResult = Invoke-WebRequest $page -UseBasicParsing
438-
$prototypeLink = $webResult.Links | Select-Object -ExpandProperty href -ErrorAction SilentlyContinue | Where-Object {
439-
$link = $_
440-
441-
foreach ( $installer in $installerTemplates.Keys ) {
442-
foreach ( $template in $installerTemplates[$installer] ) {
443-
if ( $link -like "*$template*" ) { return $true }
438+
$prototypeLink = $webResult.Links |
439+
Select-Object -ExpandProperty href -ErrorAction SilentlyContinue |
440+
Where-Object {
441+
$link = $_
442+
443+
foreach ( $installer in $installerTemplates.Keys ) {
444+
foreach ( $template in $installerTemplates[$installer] ) {
445+
if ( $link -like "*$template*" ) { return $true }
446+
}
444447
}
445-
}
446448

447-
return $false
449+
return $false
448450

449-
} | Select-Object -First 1
451+
} |
452+
Select-Object -First 1
450453

451454
if ($null -ne $prototypeLink) { break }
452455
}
@@ -465,10 +468,10 @@ function Find-UnitySetupInstaller {
465468
$knownBaseUrls = $linkComponents[0], $knownBaseUrls
466469
}
467470
else {
468-
$knownBaseUrls = $knownBaseUrls | Sort-Object -Property @{ Expression = {[math]::Abs(($_.CompareTo($linkComponents[0])))}; Ascending = $true}
471+
$knownBaseUrls = $knownBaseUrls | Sort-Object -Property @{ Expression = { [math]::Abs(($_.CompareTo($linkComponents[0]))) }; Ascending = $true }
469472
}
470473

471-
$installerTemplates.Keys | Where-Object { $Components -band $_ } | ForEach-Object {
474+
$installerTemplates.Keys | Where-Object { $Components -band $_ } | ForEach-Object {
472475
$templates = $installerTemplates.Item($_);
473476
$result = $null
474477
foreach ($template in $templates ) {
@@ -679,7 +682,7 @@ function Request-UnitySetupInstaller {
679682
$downloads = @()
680683

681684
try {
682-
$global:downloadData = [ordered]@{}
685+
$global:downloadData = [ordered]@{ }
683686
$downloadIndex = 1
684687

685688
$allInstallers | ForEach-Object {
@@ -934,7 +937,7 @@ function Install-UnitySetupInstance {
934937
$defaultInstallPath = $BasePath
935938
}
936939

937-
$versionInstallers = @{}
940+
$versionInstallers = @{ }
938941
}
939942
process {
940943
# Sort each installer received from the pipe into versions
@@ -1170,7 +1173,7 @@ function Get-UnitySetupInstanceVersion {
11701173
[CmdletBinding()]
11711174
param(
11721175
[ValidateNotNullOrEmpty()]
1173-
[ValidateScript( {Test-Path $_ -PathType Container})]
1176+
[ValidateScript( { Test-Path $_ -PathType Container })]
11741177
[Parameter(Mandatory = $true, Position = 0)]
11751178
[string]$Path
11761179
)
@@ -1322,11 +1325,11 @@ function Get-UnityProjectInstance {
13221325

13231326
Get-ChildItem @args |
13241327
ForEach-Object {
1325-
$path = [io.path]::Combine($_.FullName, "ProjectVersion.txt")
1326-
if ( Test-Path $path ) {
1327-
[UnityProjectInstance]::new((Join-Path $_.FullName "..\" | Convert-Path))
1328+
$path = [io.path]::Combine($_.FullName, "ProjectVersion.txt")
1329+
if ( Test-Path $path ) {
1330+
[UnityProjectInstance]::new((Join-Path $_.FullName "..\" | Convert-Path))
1331+
}
13281332
}
1329-
}
13301333
}
13311334

13321335
<#
@@ -1607,8 +1610,8 @@ function Start-UnityEditor {
16071610
if ( $instanceArgs[$i] ) { $unityArgs += $instanceArgs[$i] }
16081611

16091612
$actionString = "$editor $unityArgs"
1610-
if ( $Credential ) { $actionString += " -password (hidden)"}
1611-
if ( $Serial ) { $actionString += " -serial (hidden)"}
1613+
if ( $Credential ) { $actionString += " -password (hidden)" }
1614+
if ( $Serial ) { $actionString += " -serial (hidden)" }
16121615

16131616
if (-not $PSCmdlet.ShouldProcess($actionString, "System.Diagnostics.Process.Start()")) {
16141617
continue

0 commit comments

Comments
 (0)