|
| 1 | +<# |
| 2 | + .SYNOPSIS |
| 3 | + Builds a version of the Sublime Text PowerShell package and deploys it |
| 4 | + locally to Data/Packages/PowerShell. |
| 5 | +
|
| 6 | + .DESCRIPTION |
| 7 | + Builds a version of the Sublime Text PowerShell package and deploys it |
| 8 | + locally to Data/Packages/PowerShell. |
| 9 | +
|
| 10 | + Requires a configuration file in ~\.sublime-package-dev.json. |
| 11 | + |
| 12 | + This file must contain the following keys: |
| 13 | +
|
| 14 | + { |
| 15 | + "pathToSublimeText": ...\sublime_text.exe, |
| 16 | + "pathToSublimeTextData": ... |
| 17 | + } |
| 18 | +#> |
| 19 | +[CmdletBinding()] |
| 20 | +param([switch]$Release) |
| 21 | + |
| 22 | +. $PSScriptRoot\Config.ps1 |
| 23 | + |
| 24 | +$pathToInstalledPackages = join-path (GetConfigValue pathToSublimeTextData) 'Installed Packages' |
| 25 | +test-path $pathToInstalledPackages -erroraction stop > $null |
| 26 | +$pathToPackages = join-path (GetConfigValue pathToSublimeTextData) 'Packages' |
| 27 | +test-path $pathToPackages -erroraction stop > $null |
| 28 | +$pathToPowerShellPackage = join-path $pathToPackages 'PowerShell' |
| 29 | + |
| 30 | +# Deploy package locally. |
| 31 | +push-location $PSScriptRoot\.. |
| 32 | + if (test-path $pathToPowerShellPackage) { |
| 33 | + write-verbose "Deleting old files..." |
| 34 | + remove-item $pathToPowerShellPackage\* -recurse |
| 35 | + } |
| 36 | + else { |
| 37 | + write-verbose "Creating target directory..." |
| 38 | + new-item -itemtype directory $pathToPowerShellPackage |
| 39 | + } |
| 40 | + write-verbose "Copying files..." |
| 41 | + copy-item * -recurse -exclude 'dist' $pathToPowerShellPackage |
| 42 | +pop-location |
| 43 | + |
| 44 | +# Restart editor. |
| 45 | +write-verbose "Restarting editor..." |
| 46 | +get-process sublime_text -erroraction silentlycontinue | stop-process -erroraction silentlycontinue |
| 47 | +start-sleep -milliseconds 250 |
| 48 | + |
| 49 | +$editor = GetConfigValue pathToSublimeText |
| 50 | +if(!(test-path $editor -erroraction stop)){ |
| 51 | + write-error "Could not locate editor executable in '$editor'." |
| 52 | + exit 1 |
| 53 | +} |
| 54 | +& $editor |
0 commit comments