Skip to content

Commit 070c7d6

Browse files
committed
Merge pull request #117 from guillermooo-forks/fix-build-scripts
Fix build scripts
2 parents 540a61e + 7f84057 commit 070c7d6

File tree

9 files changed

+93
-203
lines changed

9 files changed

+93
-203
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
## Contributing
22

3-
43
Thanks for taking an insterest in contributing to the PowerShell package for
54
Sublime Text 3!
65

@@ -11,6 +10,32 @@ Development happens on the **dev** branch. Please send your PRs against that
1110
branch only.
1211

1312

13+
### Building Development Versions
14+
15+
To build development versions, first you need a configuration file in
16+
`$env:USERPROFILE\sublime-package-dev.json`.
17+
18+
This file must contain the following information:
19+
20+
{
21+
"pathToSublimeText": "...\sublime_text.exe",
22+
"pathToSublimeTextData": "...\
23+
}
24+
25+
26+
#### Using Sublime Text
27+
28+
1. Press <kbd>Ctrl+Shift+B</kbd> to open the build systems menu.
29+
2. Select 'PowerShell: Build Dev Version'
30+
31+
32+
#### Using the Command Line
33+
34+
From the project's root:
35+
36+
.\bin\BuildFolder.ps1 -verbose
37+
38+
1439
#### Running Tests
1540

1641
If you are adding functionality or making substantial changes to existing
@@ -20,12 +45,3 @@ Currently, we have very few tests and they aren't easy to run... :-(
2045

2146
If you feel lazy about writing tests, this is the right time to contribute --
2247
we'll turn a blind eye more often now than later on! ;-)
23-
24-
25-
### Building Versions
26-
27-
The easiest way to 'build' a version now consists in copying the project's
28-
root folder's content to your *Data/Packages/PowerShell* directory.
29-
30-
We have build scripts under *.\bin*, but they aren't realiable. We hope to fix
31-
that soon.

PowerShell.sublime-project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
"build_systems": [
1111
{
12-
"name": "Run",
13-
"shell_cmd": "powershell.exe -noninteractive -file $project_path/bin/Build-Folder.ps1"
12+
"name": "PowerShell: Build Dev Version",
13+
"shell_cmd": "powershell.exe -noninteractive -file $project_path/bin/BuildFolder.ps1"
1414
}
1515
]
1616
}

bin/Build-Folder.ps1

Lines changed: 0 additions & 54 deletions
This file was deleted.

bin/Build.ps1

Lines changed: 0 additions & 32 deletions
This file was deleted.

bin/BuildFolder.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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

bin/CleanUp.ps1

Lines changed: 0 additions & 10 deletions
This file was deleted.

bin/Config.ps1

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
1-
# Helpers to read files in this format:
2-
#
3-
# global-win editor path/to/some/bin
4-
# project-foo deploy-url http://some/url/here
5-
# ...
1+
# Helpers to read files in json.
62

7-
function GetConfig {
8-
$path = "~/.sublime-package-dev"
3+
$script:pathToConfig = "~/.sublime-package-dev.json"
94

10-
if(!(test-path $path)){
11-
write-error "Could not find personal configuration in $path."
12-
exit 1
13-
}
14-
get-content $path
15-
}
5+
function GetConfigData {
6+
if(!(test-path $pathToConfig)){
7+
write-error "Could not find configuration file '$pathToConfig'."
8+
exit 1
9+
}
1610

17-
$script:configData = GetConfig
11+
return (get-content $pathToConfig) -join "`n" | convertfrom-json
12+
}
1813

1914
function GetConfigValue {
20-
param($section, $key)
21-
$section = $section.ToLower()
22-
$key = $key.ToLower()
23-
foreach($item in $configData){
24-
if(!$item.Trim()){
25-
continue
26-
}
27-
$s, $k, $v = $item.ToLower() -split ' ',3
28-
if(($s -eq $section) -and ($k -eq $key)){
29-
if(!$v){
30-
throw "No value found for '${section}:$key'."
31-
}
32-
return $v
33-
}
34-
}
15+
param($key)
16+
return (GetConfigData).$key
3517
}

bin/MakeRelease.ps1

Lines changed: 0 additions & 20 deletions
This file was deleted.

bin/Publish.ps1

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)