Skip to content

Commit 34f1ca4

Browse files
Add LinkEditorServices task for developers (#3623)
This allows developers to use a symbolic link to their PowerShell Editor Services build instead of copying it, resulting in much faster extension build times.
1 parent 4fe1259 commit 34f1ca4

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

docs/development.md

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ This will compile the TypeScript files in the project to JavaScript files.
3838
Invoke-Build Build
3939
```
4040

41+
As a developer, you may want to use `Invoke-Build LinkEditorServices` to setup a symbolic
42+
link to its modules instead of copying the files. This will mean the built extension will
43+
always have the latest version of your PowerShell Editor Services build, but this cannot
44+
be used to package the extension into a VSIX. So it is a manual step.
45+
4146
### Launching the extension
4247

4348
#### From Visual Studio Code

modules/README.md

-8
This file was deleted.

vscode-powershell.build.ps1

+13-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ task Restore -If { !(Test-Path "$PSScriptRoot/node_modules") } {
3939

4040
task Clean {
4141
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
42-
Remove-Item ./modules -Exclude "README.md" -Recurse -Force -ErrorAction Ignore
42+
Remove-Item ./modules -Recurse -Force -ErrorAction Ignore
4343
Remove-Item ./out -Recurse -Force -ErrorAction Ignore
4444
Remove-Item ./node_modules -Recurse -Force -ErrorAction Ignore
4545
}
@@ -57,9 +57,15 @@ task BuildEditorServices -If (Get-EditorServicesPath) {
5757
Invoke-Build Build (Get-EditorServicesPath)
5858
}
5959

60-
task CopyEditorServices -If { !(Test-Path ./modules/PowerShellEditorServices) -and (Get-EditorServicesPath) } BuildEditorServices, {
61-
Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green
62-
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module/*" ./modules
60+
task LinkEditorServices -If (Get-EditorServicesPath) BuildEditorServices, {
61+
Write-Host "`n### For developer use only! Creating symbolic link to PSES" -ForegroundColor Green
62+
Remove-Item ./modules -Recurse -Force -ErrorAction Ignore
63+
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
64+
}
65+
66+
task CopyEditorServices -If { !(Test-Path ./modules) -and (Get-EditorServicesPath) } BuildEditorServices, {
67+
Write-Host "`n### Copying PSES" -ForegroundColor Green
68+
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules
6369
}
6470

6571
task Build CopyEditorServices, Restore, {
@@ -111,7 +117,9 @@ task UpdateReadme -If { $script:IsPreviewExtension } {
111117
}
112118

113119
task Package UpdateReadme, Build, {
114-
assert { Test-Path ./modules/PowerShellEditorServices }
120+
assert (Test-Path ./modules/PowerShellEditorServices)
121+
assert ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!"
122+
115123
Write-Host "`n### Packaging $($script:PackageJson.name)-$($script:PackageJson.version).vsix`n" -ForegroundColor Green
116124
exec { & npm run package }
117125
}

0 commit comments

Comments
 (0)