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

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

Merged
TylerLeonhardt merged 3 commits into PowerShell:master from TylerLeonhardt:add-buildps1
Mar 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions build.ps1
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env pwsh
Copy link
Member

@TravisEz13 TravisEz13 Feb 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No copyright header

Copy link
Member Author

@TylerLeonhardt TylerLeonhardt Feb 20, 2018

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@rkeithhill rkeithhill Feb 20, 2018

Choose a reason for hiding this comment

The 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.

TylerLeonhardt reacted with thumbs up emoji
Copy link
Member

@SteveL-MSFT SteveL-MSFT Feb 21, 2018

Choose a reason for hiding this comment

The 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.

TylerLeonhardt reacted with thumbs up emoji
# 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
}
}

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