-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.ps1
44 lines (40 loc) · 1.42 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
param(
[ArgumentCompleter( {
param ( $CommandName,
$ParameterName,
$WordToComplete,
$CommandAst,
$FakeBoundParameters )
$packages = (Get-ChildItem -Directory -Path $PSScriptRoot\packages).Name
$searchBlock = { $_ -like "$WordToComplete*" }
$completion = $packages | Where-Object $searchBlock
return $completion
})]
[string]$PackageName,
[switch]$p
)
if (!(Test-Path "$PSScriptRoot\dist\")) {
mkdir "$PSScriptRoot\dist"
}
if ($PackageName -like "all") {
$packages = Get-ChildItem -Path $PSScriptRoot\packages\
foreach ($item in $packages) {
if ((Get-ChildItem $item.FullName -Filter *.nuspec).Length -gt 0) {
Write-Output "$($item.BaseName) is a chocolatey package"
choco pack (Get-ChildItem $item.FullName -Filter *.nuspec).FullName --outdir (Join-Path $PSScriptRoot "dist")
}
}
}
else {
$packagePath = "$PSScriptRoot\packages\$PackageName"
if (Test-Path $packagePath) {
choco pack "$packagePath\$packageName.nuspec" --outdir (Join-Path $PSScriptRoot "dist")
if ($p -and $?) {
$nupkg = Get-ChildItem -Path $PSScriptRoot\dist | Where-Object Name -match "$PackageName*"
choco push $nupkg
}
}
else {
Write-Host "This package does not exists!" -ForegroundColor Red
}
}