diff --git a/EthanBrown.SublimeText2.EditorPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.EditorPackages/tools/chocolateyInstall.ps1 index e76f5e5..be15821 100644 --- a/EthanBrown.SublimeText2.EditorPackages/tools/chocolateyInstall.ps1 +++ b/EthanBrown.SublimeText2.EditorPackages/tools/chocolateyInstall.ps1 @@ -27,6 +27,8 @@ try { Copy-Item @params } + $packageCache = Join-Path (Get-CurrentDirectory) 'PackageCache' + Install-SublimePackagesFromCache -Directory $packageCache Install-SublimePackageControl $packageControl = Join-Path $current 'Package Control.sublime-settings' Merge-PackageControlSettings -FilePath $packageControl diff --git a/EthanBrown.SublimeText2.GitPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.GitPackages/tools/chocolateyInstall.ps1 index 459dc07..c8f7c02 100644 --- a/EthanBrown.SublimeText2.GitPackages/tools/chocolateyInstall.ps1 +++ b/EthanBrown.SublimeText2.GitPackages/tools/chocolateyInstall.ps1 @@ -27,6 +27,8 @@ try { Copy-Item @params } + $packageCache = Join-Path (Get-CurrentDirectory) 'PackageCache' + Install-SublimePackagesFromCache -Directory $packageCache Install-SublimePackageControl $packageControl = Join-Path $current 'Package Control.sublime-settings' Merge-PackageControlSettings -FilePath $packageControl diff --git a/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 index 01194be..e1c07f1 100644 --- a/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 +++ b/EthanBrown.SublimeText2.UtilPackages/tools/chocolateyInstall.ps1 @@ -30,6 +30,8 @@ try { ([IO.File]::ReadAllText($sublimeFiles)) -replace '{{term_command}}', $escapedPs | Out-File -FilePath (Join-Path $sublimeUserDataPath $sublimeFilesFileName) -Force -Encoding ASCII + $packageCache = Join-Path (Get-CurrentDirectory) 'PackageCache' + Install-SublimePackagesFromCache -Directory $packageCache Install-SublimePackageControl $packageControl = (Join-Path (Get-CurrentDirectory) 'Package Control.sublime-settings') Merge-PackageControlSettings -FilePath $packageControl diff --git a/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 index 1a897dc..f010e11 100644 --- a/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 +++ b/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 @@ -49,6 +49,8 @@ try { ([IO.File]::ReadAllText($grunt)) -replace '{{node_path}}', $escapedNodeRoot | Out-File -FilePath (Join-Path $sublimeUserDataPath $gruntFileName) -Force -Encoding ASCII + $packageCache = Join-Path (Get-CurrentDirectory) 'PackageCache' + Install-SublimePackagesFromCache -Directory $packageCache Install-SublimePackageControl $packageControl = (Join-Path $current 'Package Control.sublime-settings') Merge-PackageControlSettings -FilePath $packageControl diff --git a/core/SublimeHelpers.ps1 b/core/SublimeHelpers.ps1 index 8ae0909..bcfa23a 100644 --- a/core/SublimeHelpers.ps1 +++ b/core/SublimeHelpers.ps1 @@ -24,6 +24,30 @@ function Get-SublimeUserPath return $path } +function Install-SublimePackagesFromCache +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Directory + ) + + $packagesPath = Get-SublimePackagesPath + Get-ChildItem $Directory | + ? { $_.PsIsContainer } | + % { @{Path = $_.FullName; Destination = Join-Path $packagesPath $_.Name }} | + ? { + $exists = Test-Path $_.Destination + if ($exists) { Write-Host "[ ] Skipping existing $($_.Destination)" } + return !$exists + } | + % { + Write-Host "[+] Copying cached package $($_.Destination)" + Copy-Item @_ -Recurse + } +} + function Install-SublimePackageControl { # install package control