Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6ceb0d6

Browse files
add build.ps1 to align with PSES and other PowerShell projects (#1199)
* add build.ps1 * travis feedback * address steve's feedback
1 parent 4383b3a commit 6ceb0d6

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

‎build.ps1‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env pwsh
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License.
4+
5+
param(
6+
[Parameter(ParameterSetName="Bootstrap")]
7+
[switch]
8+
$Bootstrap,
9+
10+
[Parameter(ParameterSetName="Build")]
11+
[switch]
12+
$Clean,
13+
14+
[Parameter(ParameterSetName="Build")]
15+
[switch]
16+
$Test
17+
)
18+
19+
$NeededTools = @{
20+
VSCode = "Visual Studio Code"
21+
NodeJS = "Node.js 6.0 or higher"
22+
PowerShellGet = "PowerShellGet latest"
23+
InvokeBuild = "InvokeBuild latest"
24+
}
25+
26+
function needsVSCode () {
27+
try {
28+
$vscodeVersion = (code -v)
29+
if (-not $vscodeVersion) {
30+
Throw
31+
}
32+
} catch {
33+
try {
34+
$vscodeInsidersVersion = (code-insiders -v)
35+
if (-not $vscodeInsidersVersion) {
36+
Throw
37+
}
38+
} catch {
39+
return $true
40+
}
41+
}
42+
return $false
43+
}
44+
45+
function needsNodeJS () {
46+
try {
47+
$nodeJSVersion = (node -v)
48+
49+
} catch {
50+
return $true
51+
}
52+
return ($nodeJSVersion.Substring(1,1) -lt 6)
53+
}
54+
55+
function needsPowerShellGet () {
56+
if (Get-Module -ListAvailable -Name PowerShellGet) {
57+
return $false
58+
}
59+
return $true
60+
}
61+
62+
function needsInvokeBuild () {
63+
if (Get-Module -ListAvailable -Name InvokeBuild) {
64+
return $false
65+
}
66+
return $true
67+
}
68+
69+
function getMissingTools () {
70+
$missingTools = @()
71+
72+
if (needsVSCode) {
73+
$missingTools += $NeededTools.VSCode
74+
}
75+
if (needsNodeJS) {
76+
$missingTools += $NeededTools.NodeJS
77+
}
78+
if (needsPowerShellGet) {
79+
$missingTools += $NeededTools.PowerShellGet
80+
}
81+
if (needsInvokeBuild) {
82+
$missingTools += $NeededTools.InvokeBuild
83+
}
84+
85+
return $missingTools
86+
}
87+
88+
function hasMissingTools () {
89+
return ((getMissingTools).Count -gt 0)
90+
}
91+
92+
if ($Bootstrap) {
93+
$string = "Here is what your environment is missing:`n"
94+
$missingTools = getMissingTools
95+
if (($missingTools).Count -eq 0) {
96+
$string += "* nothing!`n`n Run this script without a flag to build or a -Clean to clean."
97+
} else {
98+
$missingTools | ForEach-Object {$string += "* $_`n"}
99+
$string += "`nAll instructions for installing these tools can be found on VSCode PowerShell's Github:`n" `
100+
+ "https://github.com/PowerShell/vscode-powershell/blob/master/docs/development.md"
101+
}
102+
Write-Host "`n$string`n"
103+
} elseif(hasMissingTools) {
104+
Write-Host "You are missing needed tools. Run './build.ps1 -Bootstrap' to see what they are."
105+
} else {
106+
if($Clean) {
107+
Invoke-Build Clean
108+
}
109+
110+
Invoke-Build Build
111+
112+
if($Test) {
113+
Invoke-Build Test
114+
}
115+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /