Skip to content

Commit 1799c3f

Browse files
authored
Merge pull request #6 from jwittner/dev/passThruFlag
Add PassThru flag
2 parents 598c822 + 8eddfc2 commit 1799c3f

File tree

2 files changed

+15
-39
lines changed

2 files changed

+15
-39
lines changed

UnitySetup/UnitySetup.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
RootModule = 'UnitySetup'
1515

1616
# Version number of this module.
17-
ModuleVersion = '1.4'
17+
ModuleVersion = '1.5'
1818

1919
# Supported PSEditions
2020
# CompatiblePSEditions = @()

UnitySetup/UnitySetup.psm1

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ function Select-UnitySetupInstance
225225
Should the Unity Editor quit after it's done?
226226
.PARAMETER Wait
227227
Should the command wait for the Unity Editor to exit?
228+
.PARAMETER PassThru
229+
Should the command return the process object? Default is nothing.
228230
.EXAMPLE
229231
Start-UnityEditor
230232
.EXAMPLE
@@ -251,7 +253,9 @@ function Start-UnityEditor
251253
[parameter(Mandatory = $false)]
252254
[switch] $Quit,
253255
[parameter(Mandatory = $false)]
254-
[switch] $Wait
256+
[switch] $Wait,
257+
[parameter(Mandatory = $false)]
258+
[switch] $PassThru
255259
)
256260

257261
if( $Instance -eq $null )
@@ -276,43 +280,13 @@ function Start-UnityEditor
276280

277281
$editor = Get-ChildItem "$unityPath" -Filter Unity.exe -Recurse | Select-Object -First 1 -ExpandProperty FullName
278282

279-
$args = @()
280-
$args += "-projectPath"
281-
$args += $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Project)
282-
283-
if( $ExecuteMethod )
284-
{
285-
$args += "-executeMethod"
286-
$args += $ExecuteMethod
287-
}
288-
289-
if( $OutputPath )
290-
{
291-
$args += "-buildOutput"
292-
$args += $OutputPath
293-
}
294-
295-
if( $LogFile )
296-
{
297-
$args += "-logFile"
298-
$args += $LogFile
299-
}
300-
301-
if( $BuildTarget )
302-
{
303-
$args += "-buildTarget"
304-
$args += $BuildTarget
305-
}
306-
307-
if( $BatchMode )
308-
{
309-
$args += "-batchmode"
310-
}
311-
312-
if( $Quit )
313-
{
314-
$args += "-quit"
315-
}
283+
$args = "-projectPath", $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Project)
284+
if( $ExecuteMethod ) { $args += "-executeMethod", $ExecuteMethod }
285+
if( $OutputPath ) { $args += "-buildOutput", $OutputPath }
286+
if( $LogFile ) { $args += "-logFile", $LogFile }
287+
if( $BuildTarget ) { $args += "-buildTarget", $BuildTarget }
288+
if( $BatchMode ) { $args += "-batchmode" }
289+
if( $Quit ) { $args += "-quit" }
316290

317291
Write-Host "$editor $args" -ForegroundColor Green
318292
$process = Start-Process -FilePath $editor -ArgumentList $args -PassThru -ErrorAction Stop
@@ -330,4 +304,6 @@ function Start-UnityEditor
330304
throw "Unity quit with non-zero exit code"
331305
}
332306
}
307+
308+
if( $PassThru ) { $process }
333309
}

0 commit comments

Comments
 (0)