11
11
12
12
# Grab package.json data which is used throughout the build.
13
13
$script :PackageJson = Get-Content - Raw $PSScriptRoot / package.json | ConvertFrom-Json
14
- $script :IsPreviewExtension = $script :PackageJson.name -like " *preview*" -or $script :PackageJson.displayName -like " *preview*"
15
14
Write-Host " `n ### Extension: $ ( $script :PackageJson.name ) -$ ( $script :PackageJson.version ) `n " - ForegroundColor Green
16
15
17
16
function Get-EditorServicesPath {
@@ -32,9 +31,9 @@ task RestoreNodeModules -If { !(Test-Path ./node_modules) } {
32
31
# When in a CI build use the --loglevel=error parameter so that
33
32
# package install warnings don't cause PowerShell to throw up
34
33
if ($env: TF_BUILD ) {
35
- exec { & npm ci -- loglevel= error }
34
+ Invoke-BuildExec { & npm ci -- loglevel= error }
36
35
} else {
37
- exec { & npm install }
36
+ Invoke-BuildExec { & npm install }
38
37
}
39
38
}
40
39
@@ -45,7 +44,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) {
45
44
# that developers always have the latest local bits.
46
45
if ((Get-Item ./ modules - ErrorAction SilentlyContinue).LinkType -ne " SymbolicLink" ) {
47
46
Write-Host " `n ### Creating symbolic link to PSES" - ForegroundColor Green
48
- remove ./ modules
47
+ Remove-BuildItem ./ modules
49
48
New-Item - ItemType SymbolicLink - Path ./ modules - Target " $ ( Split-Path (Get-EditorServicesPath )) /module"
50
49
}
51
50
@@ -57,7 +56,7 @@ task RestoreEditorServices -If (Get-EditorServicesPath) {
57
56
# and only if they don't already exist.
58
57
if ((Get-Item ./ modules - ErrorAction SilentlyContinue).LinkType -eq " SymbolicLink" ) {
59
58
Write-Host " `n ### Deleting PSES symbolic link" - ForegroundColor Green
60
- remove ./ modules
59
+ Remove-BuildItem ./ modules
61
60
}
62
61
63
62
if (! (Test-Path ./ modules)) {
@@ -81,7 +80,7 @@ task Restore RestoreEditorServices, RestoreNodeModules
81
80
82
81
task Clean {
83
82
Write-Host " `n ### Cleaning vscode-powershell`n " - ForegroundColor Green
84
- remove ./ modules, ./ out, ./ node_modules, * .vsix
83
+ Remove-BuildItem ./ modules, ./ out, ./ node_modules, * .vsix
85
84
}
86
85
87
86
task CleanEditorServices - If (Get-EditorServicesPath ) {
@@ -94,9 +93,9 @@ task CleanEditorServices -If (Get-EditorServicesPath) {
94
93
95
94
task Build Restore, {
96
95
Write-Host " `n ### Building vscode-powershell`n " - ForegroundColor Green
97
- assert (Test-Path ./ modules/ PowerShellEditorServices/ bin) " Extension requires PSES"
96
+ Assert-Build (Test-Path ./ modules/ PowerShellEditorServices/ bin) " Extension requires PSES"
98
97
99
- exec { & npm run lint }
98
+ Invoke-BuildExec { & npm run lint }
100
99
101
100
# TODO: When supported we should use `esbuild` for the tests too. Although
102
101
# we now use `esbuild` to transpile, bundle, and minify the extension, we
@@ -105,8 +104,8 @@ task Build Restore, {
105
104
# Unfortunately `esbuild` doesn't support emitting 1:1 files (yet).
106
105
# https://github.com/evanw/esbuild/issues/944
107
106
switch ($Configuration ) {
108
- " Debug" { exec { & npm run build -- -- sourcemap } }
109
- " Release" { exec { & npm run build -- -- minify } }
107
+ " Debug" { Invoke-BuildExec { & npm run build -- -- sourcemap } }
108
+ " Release" { Invoke-BuildExec { & npm run build -- -- minify } }
110
109
}
111
110
}
112
111
@@ -115,9 +114,9 @@ task Build Restore, {
115
114
116
115
task Test - If (! ($env: TF_BUILD -and $global :IsLinux )) Build, {
117
116
Write-Host " `n ### Running extension tests" - ForegroundColor Green
118
- exec { & npm run test }
117
+ Invoke-BuildExec { & npm run test }
119
118
# Reset the state of files modified by tests
120
- exec { git checkout package.json test/ .vscode/ settings.json}
119
+ Invoke-BuildExec { git checkout package.json test/ .vscode/ settings.json}
121
120
}
122
121
123
122
task TestEditorServices - If (Get-EditorServicesPath ) {
@@ -128,26 +127,14 @@ task TestEditorServices -If (Get-EditorServicesPath) {
128
127
# endregion
129
128
# region Package tasks
130
129
131
- task UpdateReadme - If { $script :IsPreviewExtension } {
132
- # Add the preview text
133
- $newReadmeTop = ' # PowerShell Language Support for Visual Studio Code
134
-
135
- > ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable. It works with PowerShell 5.1 and up.
136
- > ### If you are looking for the stable version, please [go here](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) or install the extension called "PowerShell" (not "PowerShell Preview")
137
- > ## NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, you MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)'
138
- $readmePath = (Join-Path $PSScriptRoot README.md)
139
-
140
- $readmeContent = Get-Content - Path $readmePath
141
- if (! ($readmeContent -match " This is the PREVIEW version of the PowerShell extension" )) {
142
- $readmeContent [0 ] = $newReadmeTop
143
- $readmeContent | Set-Content $readmePath - Encoding utf8
144
- }
145
- }
146
-
147
- task Package UpdateReadme, Build, {
130
+ task Package Build, {
148
131
Write-Host " `n ### Packaging $ ( $script :PackageJson.name ) -$ ( $script :PackageJson.version ) .vsix`n " - ForegroundColor Green
149
- assert ((Get-Item ./ modules).LinkType -ne " SymbolicLink" ) " Packaging requires a copy of PSES, not a symlink!"
150
- exec { & npm run package }
132
+ Assert-Build ((Get-Item ./ modules).LinkType -ne " SymbolicLink" ) " Packaging requires a copy of PSES, not a symlink!"
133
+ if ($script :PackageJson.preview ) {
134
+ Invoke-BuildExec { & npm run package -- -- pre- release }
135
+ } else {
136
+ Invoke-BuildExec { & npm run package }
137
+ }
151
138
}
152
139
153
140
# endregion
0 commit comments