-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
1.build.ps1
88 lines (73 loc) · 2.18 KB
/
1.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<#
.Synopsis
Build script, https://github.com/nightroman/Invoke-Build
#>
param(
[string[]]$Tasks
)
Set-StrictMode -Version Latest
$Major = $PSVersionTable.PSVersion.Major
# bootstrap
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
$InvokeBuildVersion = '5.11.0'
$ErrorActionPreference = 1
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Definition
$ib = "$PSScriptRoot/packages/InvokeBuild/$InvokeBuildVersion/Invoke-Build.ps1"
if (!(Test-Path -LiteralPath $ib)) {
Write-Host 'Save-Module InvokeBuild'
Save-Module InvokeBuild -Path "$PSScriptRoot/packages" -RequiredVersion $InvokeBuildVersion -Force
}
if (!(Test-Path -LiteralPath "$PSScriptRoot/packages/Invoke-PowerShell.ps1")) {
Write-Host 'Save-Script Invoke-PowerShell'
Save-Script Invoke-PowerShell -Path "$PSScriptRoot/packages" -Force
}
return & $ib -Task $Tasks -File $MyInvocation.MyCommand.Path @PSBoundParameters
}
# saved script alias
if (Test-Path "$BuildRoot/packages/Invoke-PowerShell.ps1") {
Set-Alias Invoke-PowerShell "$BuildRoot/packages/Invoke-PowerShell.ps1"
}
# custom task header
Set-BuildHeader {
Write-Build 11 "Task $($args[0]) *".PadRight(79, '*')
}
# Synopsis: Invoke tests.
task test {
# show PowerShell version
"PowerShell version: $($PSVersionTable.PSVersion)"
# do tests
Invoke-Build **
}
# Synopsis: Open a random folder in Visual Studio Code
task peek {
code (Get-ChildItem . -Recurse -Directory | Get-Random).FullName
}
# Synopsis: Generate README index.
task index {
# https://www.powershellgallery.com/packages/Update-ReadmeIndex
$param = @{
Depth = 99
Skip = { $args[0] -like '*workaround*' }
}
Update-ReadmeIndex.ps1 Basic @param
Update-ReadmeIndex.ps1 Class @param
Update-ReadmeIndex.ps1 Clixml @param
Update-ReadmeIndex.ps1 Cmdlets @param
Update-ReadmeIndex.ps1 Module @param
Update-ReadmeIndex.ps1 PowerShell.exe @param
}
task linkMarkdown {
Test-MarkdownLink.ps1
}
task linkWeb {
Test-WebLink.ps1 -SkipUrl {
param($Url)
$Url -in @(
'https://api.github.com/users/nightroman/repos'
)
}
}
# Synopsis: Test links.
task link linkMarkdown, linkWeb
# Synopsis: Test.
task . test