-
Notifications
You must be signed in to change notification settings - Fork 520
add build.ps1 to align with PSES and other PowerShell projects #1199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| #!/usr/bin/env pwsh | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No copyright header There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added. Wasn't sure which should be on top. Let me know if I have it wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My testing indicates that the shebang has to be on the first line of the script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, shebang must be first line. This would be the exception to the copyright header rule being first. |
||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| param( | ||
| [Parameter(ParameterSetName="Bootstrap")] | ||
| [switch] | ||
| $Bootstrap, | ||
|
|
||
| [Parameter(ParameterSetName="Build")] | ||
| [switch] | ||
| $Clean, | ||
|
|
||
| [Parameter(ParameterSetName="Build")] | ||
| [switch] | ||
| $Test | ||
| ) | ||
|
|
||
| $NeededTools = @{ | ||
| VSCode = "Visual Studio Code" | ||
| NodeJS = "Node.js 6.0 or higher" | ||
| PowerShellGet = "PowerShellGet latest" | ||
| InvokeBuild = "InvokeBuild latest" | ||
| } | ||
|
|
||
| function needsVSCode () { | ||
| try { | ||
| $vscodeVersion = (code -v) | ||
| if (-not $vscodeVersion) { | ||
| Throw | ||
| } | ||
| } catch { | ||
| try { | ||
| $vscodeInsidersVersion = (code-insiders -v) | ||
| if (-not $vscodeInsidersVersion) { | ||
| Throw | ||
| } | ||
| } catch { | ||
| return $true | ||
| } | ||
| } | ||
| return $false | ||
| } | ||
|
|
||
| function needsNodeJS () { | ||
| try { | ||
| $nodeJSVersion = (node -v) | ||
|
|
||
| } catch { | ||
| return $true | ||
| } | ||
| return ($nodeJSVersion.Substring(1,1) -lt 6) | ||
| } | ||
|
|
||
| function needsPowerShellGet () { | ||
| if (Get-Module -ListAvailable -Name PowerShellGet) { | ||
| return $false | ||
| } | ||
| return $true | ||
| } | ||
|
|
||
| function needsInvokeBuild () { | ||
| if (Get-Module -ListAvailable -Name InvokeBuild) { | ||
| return $false | ||
| } | ||
| return $true | ||
| } | ||
|
|
||
| function getMissingTools () { | ||
| $missingTools = @() | ||
|
|
||
| if (needsVSCode) { | ||
| $missingTools += $NeededTools.VSCode | ||
| } | ||
| if (needsNodeJS) { | ||
| $missingTools += $NeededTools.NodeJS | ||
| } | ||
| if (needsPowerShellGet) { | ||
| $missingTools += $NeededTools.PowerShellGet | ||
| } | ||
| if (needsInvokeBuild) { | ||
| $missingTools += $NeededTools.InvokeBuild | ||
| } | ||
|
|
||
| return $missingTools | ||
| } | ||
|
|
||
| function hasMissingTools () { | ||
| return ((getMissingTools).Count -gt 0) | ||
| } | ||
|
|
||
| if ($Bootstrap) { | ||
| $string = "Here is what your environment is missing:`n" | ||
| $missingTools = getMissingTools | ||
| if (($missingTools).Count -eq 0) { | ||
| $string += "* nothing!`n`n Run this script without a flag to build or a -Clean to clean." | ||
| } else { | ||
| $missingTools | ForEach-Object {$string += "* $_`n"} | ||
| $string += "`nAll instructions for installing these tools can be found on VSCode PowerShell's Github:`n" ` | ||
| + "https://github.com/PowerShell/vscode-powershell/blob/master/docs/development.md" | ||
| } | ||
| Write-Host "`n$string`n" | ||
| } elseif(hasMissingTools) { | ||
| Write-Host "You are missing needed tools. Run './build.ps1 -Bootstrap' to see what they are." | ||
| } else { | ||
| if($Clean) { | ||
| Invoke-Build Clean | ||
| } | ||
|
|
||
| Invoke-Build Build | ||
|
|
||
| if($Test) { | ||
| Invoke-Build Test | ||
| } | ||
| } | ||