forked from NuGet/NuGetGallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_Common.ps1
54 lines (45 loc) · 1.25 KB
/
_Common.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
function require-param {
param($value, $paramNames)
if ($value -eq $null) {
write-error "The parameter -$paramName is required."
exit 1
}
}
function print-error {
param($value)
Write-Host $value -foregroundcolor White -backgroundcolor Red
}
function print-warning {
param($value)
Write-Host $value -foregroundcolor Red -backgroundcolor Yellow
}
function print-success {
param($value)
Write-Host $value -foregroundcolor Black -backgroundcolor Green
}
function print-message {
param($value)
Write-Host $value -foregroundcolor Black -backgroundcolor White
}
function require-Module {
param([string]$name)
if(-not(Get-Module -name $name)){
if(Get-Module -ListAvailable | Where-Object { $_.name -eq $name }) {
write-host "Module is avalible and will be loaded."
Import-Module -name $name
} else {
write-error "The module '$name' is required."
exit 1
}
}
}
function programfiles-dir {
if (is64bit -eq $true) {
(Get-Item "Env:ProgramFiles(x86)").Value
} else {
(Get-Item "Env:ProgramFiles").Value
}
}
function is64bit() {
return ([IntPtr]::Size -eq 8)
}