39 lines
1.2 KiB
PowerShell
39 lines
1.2 KiB
PowerShell
|
function Invoke-Install {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Run the install command in this or the appropriate parent folder from this folder
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
param (
|
||
|
[Parameter(Mandatory = $false, Position = 0, ValueFromRemainingArguments = $true)]
|
||
|
$CommandLineArguments
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName)
|
||
|
|
||
|
$currentFolder = (Get-Location).Path
|
||
|
$taskPath = $null
|
||
|
|
||
|
do {
|
||
|
$taskPath = $null
|
||
|
$potentialPath = (Join-Path -Path $currentFolder -ChildPath "install.ps1")
|
||
|
if (Test-Path $potentialPath) {
|
||
|
$taskPath = $potentialPath
|
||
|
break
|
||
|
}
|
||
|
$currentFolder = (Get-Item $currentFolder).Parent.Name
|
||
|
# If the current folder is the root, it has no parent, so we can't recurse again
|
||
|
if ($null -eq $currentFolder) {
|
||
|
break
|
||
|
}
|
||
|
} while ([string]::IsNullOrWhiteSpace($taskPath))
|
||
|
|
||
|
if ([string]::IsNullOrWhiteSpace($taskPath)) {
|
||
|
Write-Warning "$logLead : No install path could be found in current or parent paths."
|
||
|
return $null
|
||
|
}
|
||
|
|
||
|
Invoke-Expression "$taskPath $($CommandLineArguments -join ' ')"
|
||
|
}
|
||
|
New-Alias -Name install -Value Invoke-Install -Force
|