Skip to content

Commit b3353c0

Browse files
committed
Replace ResolveEditorServicesPath task with Get-EditorServicesPath function
1 parent 18c3732 commit b3353c0

File tree

1 file changed

+16
-39
lines changed

1 file changed

+16
-39
lines changed

vscode-powershell.build.ps1

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,15 @@ $script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-
1212
$script:IsPreviewExtension = $script:PackageJson.name -like "*preview*" -or $script:PackageJson.displayName -like "*preview*"
1313
Write-Host "`n### Extension Version: $($script:PackageJson.version) Extension Name: $($script:PackageJson.name)`n" -ForegroundColor Green
1414

15-
#region Utility tasks
16-
17-
# TODO: This needs to be a function, not a task.
18-
task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, TestEditorServices, Package {
19-
20-
$script:psesRepoPath = `
21-
if ($EditorServicesRepoPath) {
22-
$EditorServicesRepoPath
23-
}
24-
else {
25-
"$PSScriptRoot/../PowerShellEditorServices/"
26-
}
27-
28-
if (!(Test-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1")) {
29-
# Clear the path so that it won't be used
30-
Write-Warning "`nThe PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n"
31-
$script:psesRepoPath = $null
32-
}
33-
else {
34-
$script:psesRepoPath = Resolve-Path $script:psesRepoPath
35-
$script:psesBuildScriptPath = Resolve-Path "$script:psesRepoPath/PowerShellEditorServices.build.ps1"
15+
function Get-EditorServicesPath {
16+
$psesRepoPath = if ($EditorServicesRepoPath) {
17+
$EditorServicesRepoPath
18+
} else {
19+
"$PSScriptRoot/../PowerShellEditorServices/"
3620
}
21+
return Resolve-Path "$psesRepoPath/PowerShellEditorServices.build.ps1"
3722
}
3823

39-
#endregion
4024
#region Restore tasks
4125

4226
task Restore RestoreNodeModules -If { -not (Test-Path "$PSScriptRoot/node_modules") }
@@ -61,11 +45,9 @@ task Clean {
6145
Remove-Item -Force -Recurse node_modules -ErrorAction Ignore
6246
}
6347

64-
task CleanEditorServices {
65-
if ($script:psesBuildScriptPath) {
66-
Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
67-
Invoke-Build Clean $script:psesBuildScriptPath
68-
}
48+
task CleanEditorServices -If (Get-EditorServicesPath) {
49+
Write-Host "`n### Cleaning PowerShellEditorServices`n" -ForegroundColor Green
50+
Invoke-Build Clean (Get-EditorServicesPath)
6951
}
7052

7153
task CleanAll CleanEditorServices, Clean
@@ -78,12 +60,9 @@ task Build Restore, {
7860
exec { & npm run compile }
7961
}
8062

81-
task BuildEditorServices {
82-
# If the PSES codebase is co-located, build it first
83-
if ($script:psesBuildScriptPath) {
84-
Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
85-
Invoke-Build Build $script:psesBuildScriptPath
86-
}
63+
task BuildEditorServices -If (Get-EditorServicesPath) {
64+
Write-Host "`n### Building PowerShellEditorServices`n" -ForegroundColor Green
65+
Invoke-Build Build (Get-EditorServicesPath)
8766
}
8867

8968
task BuildAll BuildEditorServices, Build
@@ -100,11 +79,9 @@ task Test Build, {
10079
exec { & npm run test }
10180
}
10281

103-
task TestEditorServices {
104-
if ($script:psesBuildScriptPath) {
105-
Write-Host "`n### Testing PowerShellEditorServices`n" -ForegroundColor Green
106-
Invoke-Build Test $script:psesBuildScriptPath
107-
}
82+
task TestEditorServices -If (Get-EditorServicesPath) {
83+
Write-Host "`n### Testing PowerShellEditorServices`n" -ForegroundColor Green
84+
Invoke-Build Test (Get-EditorServicesPath)
10885
}
10986

11087
task TestAll TestEditorServices, Test
@@ -130,7 +107,7 @@ task UpdateReadme -If { $script:IsPreviewExtension } {
130107
}
131108

132109
task Package UpdateReadme, {
133-
if ($script:psesBuildScriptPath -or $env:TF_BUILD) {
110+
if (Get-EditorServicesPath -or $env:TF_BUILD) {
134111
Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green
135112
Copy-Item -Recurse -Force ..\PowerShellEditorServices\module\* .\modules
136113
} else {

0 commit comments

Comments
 (0)