feat: SublimeHelpers.ps1 -- add support for ST3
- package control must now be git cloned manually
This commit is contained in:
@@ -1,17 +1,41 @@
|
|||||||
# uses functions in JsonHelpers.ps1
|
# uses functions in JsonHelpers.ps1
|
||||||
function Get-SublimeInstallPath
|
function Get-SublimeInstallPath
|
||||||
{
|
{
|
||||||
Join-Path $Env:ProgramFiles 'Sublime Text 2'
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
Join-Path $Env:ProgramFiles "Sublime Text $Version"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-SublimeSettingsPath
|
function Get-SublimeSettingsPath
|
||||||
{
|
{
|
||||||
Join-Path ([Environment]::GetFolderPath('ApplicationData')) 'Sublime Text 2'
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
Join-Path ([Environment]::GetFolderPath('ApplicationData')) "Sublime Text $Version"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-SublimePackagesPath
|
function Get-SublimePackagesPath
|
||||||
{
|
{
|
||||||
$packagesPath = Join-Path (Get-SublimeSettingsPath) 'Packages'
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
$packagesPath = Join-Path (Get-SublimeSettingsPath -Version $Version) 'Packages'
|
||||||
if (!(Test-Path $packagesPath))
|
if (!(Test-Path $packagesPath))
|
||||||
{
|
{
|
||||||
New-Item $packagesPath -Type Directory | Out-Null
|
New-Item $packagesPath -Type Directory | Out-Null
|
||||||
@@ -22,7 +46,15 @@ function Get-SublimePackagesPath
|
|||||||
|
|
||||||
function Get-SublimeUserPath
|
function Get-SublimeUserPath
|
||||||
{
|
{
|
||||||
$path = Join-Path (Get-SublimePackagesPath) 'User'
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
$path = Join-Path (Get-SublimePackagesPath -Version $Version) 'User'
|
||||||
if (!(Test-Path $path))
|
if (!(Test-Path $path))
|
||||||
{
|
{
|
||||||
New-Item $path -Type Directory | Out-Null
|
New-Item $path -Type Directory | Out-Null
|
||||||
@@ -39,7 +71,7 @@ function Install-SublimePackagesFromCache
|
|||||||
$Directory
|
$Directory
|
||||||
)
|
)
|
||||||
|
|
||||||
$packagesPath = Get-SublimePackagesPath
|
$packagesPath = Get-SublimePackagesPath -Version $Version
|
||||||
Get-ChildItem $Directory |
|
Get-ChildItem $Directory |
|
||||||
? { $_.PsIsContainer } |
|
? { $_.PsIsContainer } |
|
||||||
% { @{Path = $_.FullName; Destination = Join-Path $packagesPath $_.Name }} |
|
% { @{Path = $_.FullName; Destination = Join-Path $packagesPath $_.Name }} |
|
||||||
@@ -56,16 +88,38 @@ function Install-SublimePackagesFromCache
|
|||||||
|
|
||||||
function Install-SublimePackageControl
|
function Install-SublimePackageControl
|
||||||
{
|
{
|
||||||
# install package control
|
[CmdletBinding()]
|
||||||
$packagesPath = Join-Path (Get-SublimeSettingsPath) 'Installed Packages'
|
param(
|
||||||
if (!(Test-Path $packagesPath)) { New-Item $packagesPath -Type Directory }
|
[Parameter(Mandatory = $false)]
|
||||||
$packageControl = Join-Path $packagesPath 'Package Control.sublime-package'
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
|
)
|
||||||
|
|
||||||
if (!(Test-Path $packageControl))
|
# install package control
|
||||||
|
$packageFolder = if ($Version -eq 2) { 'Installed Packages' } else { 'Packages' }
|
||||||
|
$packagesPath = Join-Path (Get-SublimeSettingsPath -Version $Version) $packageFolder
|
||||||
|
|
||||||
|
if (!(Test-Path $packagesPath)) { New-Item $packagesPath -Type Directory }
|
||||||
|
|
||||||
|
switch ($Version)
|
||||||
{
|
{
|
||||||
# http://wbond.net/sublime_packages/package_control/installation
|
2 {
|
||||||
$packageUrl = 'http://sublime.wbond.net/Package%20Control.sublime-package'
|
$packageControl = Join-Path $packagesPath 'Package Control.sublime-package'
|
||||||
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
|
|
||||||
|
if (!(Test-Path $packageControl))
|
||||||
|
{
|
||||||
|
# http://wbond.net/sublime_packages/package_control/installation
|
||||||
|
$packageUrl = 'http://sublime.wbond.net/Package%20Control.sublime-package'
|
||||||
|
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
3 {
|
||||||
|
Push-Location $packagesPath
|
||||||
|
git clone -b python3 https://github.com/wbond/sublime_package_control.git "Package Control"
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +129,15 @@ function Merge-PackageControlSettings
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]
|
[string]
|
||||||
$FilePath
|
$FilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
$root = Get-SublimeUserPath
|
$root = Get-SublimeUserPath -Version $Version
|
||||||
$existingPath = Join-Path $root 'Package Control.sublime-settings'
|
$existingPath = Join-Path $root 'Package Control.sublime-settings'
|
||||||
if (!(Test-Path $existingPath))
|
if (!(Test-Path $existingPath))
|
||||||
{
|
{
|
||||||
@@ -113,10 +172,15 @@ function Merge-Preferences
|
|||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[String]
|
[String]
|
||||||
$FilePath
|
$FilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateRange(2,3)]
|
||||||
|
[int]
|
||||||
|
$Version = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
$root = Get-SublimeUserPath
|
$root = Get-SublimeUserPath -Version $Version
|
||||||
$existingPath = Join-Path $root 'Preferences.sublime-settings'
|
$existingPath = Join-Path $root 'Preferences.sublime-settings'
|
||||||
if (!(Test-Path $existingPath))
|
if (!(Test-Path $existingPath))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user