Skip to content

Commit bb42c6e

Browse files
Add --follow-symlinks flag to VSCE and simplify build logic
Co-authored-by: andyleejordan <[email protected]>
1 parent 2873b10 commit bb42c6e

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"watch": "npm run compile -- --watch",
106106
"lint": "eslint src test --ext .ts",
107107
"format": "prettier --check '**/*.{ts,json,yml,mjs,code-workspace}'",
108-
"package": "vsce package --out out/ --no-gitHubIssueLinking",
108+
"package": "vsce package --out out/ --no-gitHubIssueLinking --follow-symlinks",
109109
"publish": "vsce publish",
110110
"pretest": "npm run compile",
111111
"test": "vscode-test"

vscode-powershell.build.ps1

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,18 @@ task RestoreEditorServices -If (Get-EditorServicesPath) {
4747
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
4848
}
4949
"Release" {
50-
# When releasing, we ensure the bits are not symlinked but copied,
51-
# and only if they don't already exist.
52-
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") {
53-
Write-Build DarkRed "Deleting PSES symbolic link"
50+
# With VSCE --follow-symlinks support, we can now use symlinks in Release mode too.
51+
# Create symlink if it doesn't exist, ensuring it points to the correct location.
52+
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -ne "SymbolicLink") {
53+
Write-Build DarkMagenta "Creating symbolic link to PSES"
5454
Remove-BuildItem ./modules
55+
New-Item -ItemType SymbolicLink -Path ./modules -Target "$(Split-Path (Get-EditorServicesPath))/module"
5556
}
5657

57-
if (!(Test-Path ./modules)) {
58-
# We only build if it hasn't been built at all.
59-
if (!(Test-Path "$(Split-Path (Get-EditorServicesPath))/module/PowerShellEditorServices/bin")) {
60-
Write-Build DarkGreen "Building PSES"
61-
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
62-
}
63-
64-
Write-Build DarkGreen "Copying PSES"
65-
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules
58+
# Only build if it hasn't been built at all.
59+
if (!(Test-Path "$(Split-Path (Get-EditorServicesPath))/module/PowerShellEditorServices/bin")) {
60+
Write-Build DarkGreen "Building PSES"
61+
Invoke-Build Build (Get-EditorServicesPath) -Configuration $Configuration
6662
}
6763
}
6864
}
@@ -132,14 +128,8 @@ task Package {
132128

133129
Assert-Build (Test-Path ./dist/extension.js) "Extension must be built!"
134130

135-
# Packaging requires a copy of the modules folder, not a symbolic link. But
136-
# we might have built in Debug configuration, not Release, and still want to
137-
# package it. So delete the symlink and copy what we just built.
138-
if ((Get-Item ./modules -ErrorAction SilentlyContinue).LinkType -eq "SymbolicLink") {
139-
Write-Build DarkRed "PSES is a symbolic link, replacing with copy!"
140-
Remove-BuildItem ./modules
141-
Copy-Item -Recurse -Force "$(Split-Path (Get-EditorServicesPath))/module" ./modules
142-
}
131+
# With --follow-symlinks flag, VSCE can now package symbolic links directly,
132+
# so we no longer need to convert symlinks to copies.
143133

144134
if ($version.Minor % 2 -ne 0) {
145135
Write-Build DarkRed "This is a pre-release!"

0 commit comments

Comments
 (0)