forked from dahlbyk/posh-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.ps1
35 lines (31 loc) · 887 Bytes
/
Utils.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# General Utility Functions
function Coalesce-Args {
$result = $null
foreach($arg in $args) {
if ($arg -is [ScriptBlock]) {
$result = & $arg
} else {
$result = $arg
}
if ($result) { break }
}
$result
}
Set-Alias ?? Coalesce-Args -Force
function Get-LocalOrParentPath($path) {
$checkIn = Get-Item .
while ($checkIn -ne $NULL) {
$pathToTest = [System.IO.Path]::Combine($checkIn.fullname, $path)
if (Test-Path $pathToTest) {
return $pathToTest
} else {
$checkIn = $checkIn.parent
}
}
return $null
}
function dbg ($Message, [Diagnostics.Stopwatch]$Stopwatch) {
if($Stopwatch) {
Write-Verbose ('{0:00000}:{1}' -f $Stopwatch.ElapsedMilliseconds,$Message) -Verbose # -ForegroundColor Yellow
}
}