-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.ps1
49 lines (36 loc) · 1.06 KB
/
Build.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function Get-ScriptPath {
<#
.SYNOPSIS
Returns the full path to the powershell running script.
.EXAMPLE
Write-Host "Script path: $(Get-ScriptPath)"
#>
return (Get-PSCallStack)[1].ScriptName | Split-Path -Parent
}
$root = Get-ScriptPath
if (!(Test-Path "$root\temp")) {
New-Item -ItemType Directory -Path "$root\temp"
git clone https://github.com/levid0s/useful.git "$root\temp\useful"
}
else {
git -C "$root\temp\useful" pull
}
Push-Location "$root\temp\useful"
$version = git rev-parse --short HEAD
Pop-Location
. "$root\temp\useful\ps-winhelpers\_PS-WinHelpers.ps1"
$FnSrc = Get-Command Register-PowerShellScheduledTask | Select-Object -ExpandProperty ScriptBlock
$FnSrc = @"
function Register-PowerShellScheduledTask {
# source: https://github.com/levid0s/useful
# commit: $version
$FnSrc
}
"@
Out-File _Helper.ps1 -InputObject $FnSrc
$FnSrc = @"
# source: https://github.com/levid0s/useful
# commit: $version
$(Get-Content -Path "$root\temp\useful\control-winapps\Control-WinApps.ps1")
"@
Out-File -FilePath .\_Helper.ps1 -InputObject $FnSrc -Append