|
| 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 | +[CmdletBinding()] |
1 | 11 | param([switch]$Release)
|
2 | 12 |
|
3 | 13 | $script:thisDir = split-path $MyInvocation.MyCommand.Path -parent
|
4 | 14 |
|
5 | 15 | . (join-path $script:thisDir "Config.ps1")
|
6 |
| - |
7 | 16 | if(!$?){
|
8 |
| - write-error "Could not read config." |
9 |
| - exit 1 |
| 17 | + write-error "Could not read configuration file." |
| 18 | + exit 1 |
10 | 19 | }
|
11 | 20 |
|
12 |
| -# copy to local folder |
| 21 | +$installedPackages = (GetConfigValue 'global-win' 'installed-packages') |
| 22 | +$packagesFolder = "$installedPackages/../Packages" |
| 23 | +$pathToPowerShellPackage = "$packagesFolder/PowerShell" |
| 24 | + |
| 25 | +# Deploy package locally. |
13 | 26 | push-location $thisDir
|
14 | 27 | push-location '..'
|
15 |
| - $installedPackages = (GetConfigValue 'global-win' 'installed-packages') |
16 |
| - write-output "copying files..." |
17 |
| - # TODO: Perhaps we should delete the folder first. |
18 |
| - copy-item * -recurse -force -exclude ".git" "$installedPackages/../Packages/PowerShell" |
| 28 | + if (test-path $pathToPowerShellPackage) { |
| 29 | + write-verbose "Deleting old files..." |
| 30 | + remove-item "$pathToPowerShellPackage/*" -recurse -force |
| 31 | + } |
| 32 | + else { |
| 33 | + write-verbose "Creating target directory..." |
| 34 | + new-item -itemtype 'directory' $pathToPowerShellPackage |
| 35 | + } |
| 36 | + write-verbose "Copying files..." |
| 37 | + copy-item * -recurse -force -exclude ".git" $pathToPowerShellPackage |
19 | 38 | pop-location
|
20 | 39 | pop-location
|
21 | 40 |
|
22 |
| -write-output "restarting editor... bye!" |
23 |
| -start-sleep -milliseconds 100 |
24 |
| -get-process "sublime_text" | stop-process |
| 41 | +# Restart editor. |
| 42 | +write-verbose "Restarting editor..." |
| 43 | +get-process "sublime_text" -erroraction 'silentlycontinue' | ` |
| 44 | + stop-process -erroraction 'silentlycontinue' |
| 45 | + |
25 | 46 | start-sleep -milliseconds 250
|
26 |
| -# sss |
| 47 | + |
27 | 48 | $editor = (GetConfigValue 'global-win' 'editor')
|
28 | 49 | if(!$?){
|
29 |
| - write-error "Could not locate editor command." |
30 |
| - exit 1 |
| 50 | + write-error "Could not locate editor command." |
| 51 | + exit 1 |
31 | 52 | }
|
32 | 53 |
|
33 | 54 | &$editor
|
0 commit comments