@@ -12,31 +12,15 @@ $script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-
12
12
$script :IsPreviewExtension = $script :PackageJson.name -like " *preview*" -or $script :PackageJson.displayName -like " *preview*"
13
13
Write-Host " `n ### Extension Version: $ ( $script :PackageJson.version ) Extension Name: $ ( $script :PackageJson.name ) `n " - ForegroundColor Green
14
14
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 " `n The 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/"
36
20
}
21
+ return Resolve-Path " $psesRepoPath /PowerShellEditorServices.build.ps1"
37
22
}
38
23
39
- # endregion
40
24
# region Restore tasks
41
25
42
26
task Restore RestoreNodeModules - If { -not (Test-Path " $PSScriptRoot /node_modules" ) }
@@ -61,11 +45,9 @@ task Clean {
61
45
Remove-Item - Force - Recurse node_modules - ErrorAction Ignore
62
46
}
63
47
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 )
69
51
}
70
52
71
53
task CleanAll CleanEditorServices, Clean
@@ -78,12 +60,9 @@ task Build Restore, {
78
60
exec { & npm run compile }
79
61
}
80
62
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 )
87
66
}
88
67
89
68
task BuildAll BuildEditorServices, Build
@@ -100,11 +79,9 @@ task Test Build, {
100
79
exec { & npm run test }
101
80
}
102
81
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 )
108
85
}
109
86
110
87
task TestAll TestEditorServices, Test
@@ -130,7 +107,7 @@ task UpdateReadme -If { $script:IsPreviewExtension } {
130
107
}
131
108
132
109
task Package UpdateReadme, {
133
- if ($ script :psesBuildScriptPath -or $env: TF_BUILD ) {
110
+ if (Get-EditorServicesPath -or $env: TF_BUILD ) {
134
111
Write-Host " `n ### Copying PowerShellEditorServices module files" - ForegroundColor Green
135
112
Copy-Item - Recurse - Force ..\PowerShellEditorServices\module\* .\modules
136
113
} else {
0 commit comments