Skip to content

Commit

Permalink
Merge pull request #46 from pwsh-cs-tools/patch-v0.5.4
Browse files Browse the repository at this point in the history
Patch (Minor): 0.5.4 - Improve TempPath Performance
  • Loading branch information
anonhostpi authored Jan 18, 2024
2 parents df642b4 + 744105b commit f613e23
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Import-Package/Import-Package.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = '.\Import-Package.psm1'

# Version number of this module.
ModuleVersion = '0.5.1'
ModuleVersion = '0.5.4'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
8 changes: 6 additions & 2 deletions Import-Package/Import-Package.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ function Get-Runtime {
.Parameter Offline
Skip downloading the package from the package provider.
.Parameter CachePath
The directory to place and load packages not provided by PackageManagement. These can be SemVer2 packages or packages provided with -Path
.Parameter TempPath
The directory to place and load native dlls from. Defaults to the current directory.
Expand Down Expand Up @@ -207,7 +210,8 @@ function Import-Package {

$mutexes."$id" = New-Object System.Threading.Mutex($true, "Global\ImportPackage-$id") # Lock the directory from automatic removal

New-Item -ItemType Directory -Path (Join-Path $parent $id) -Force
Join-Path $parent $id

# Resolve-Path "."
}
$true
Expand Down Expand Up @@ -494,7 +498,7 @@ function Import-Package {
Write-Warning "[Import-Package:Loading] $($PackageData.Name) is not needed for $( $bootstrapper.Runtime )`:$($TargetFramework.GetShortFolderName())"
}

If( $temp_path_generated ){
If( $temp_path_generated -and (Test-Path $TempPath) ){
If( Test-Path (Join-Path $TempPath "*") ){
Write-Verbose "[Import-Package:Loading] Temp files: $TempPath"
} Else {
Expand Down
5 changes: 4 additions & 1 deletion Import-Package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ Import-Package `
- TargetFramework:
- The target framework of the package to import.
- Default: TFM of the current PowerShell session.
- TempPath

- CachePath:
- The directory to place and load packages not provided by PackageManagement. These can be SemVer2 packages or packages provided with -Path
- TempPath:
- The directory to place and load native dlls from. Defaults to the current directory.


Expand Down
3 changes: 3 additions & 0 deletions Import-Package/packaging.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ public static extern IntPtr dlopen(string path, int flags);
{
param( $Path, $CopyTo )
If( $CopyTo ){
If( -not (Test-Path $CopyTo -PathType Container) ){
New-Item -ItemType Directory -Path $CopyTo -Force
}
Write-Verbose "Loading native dll from path '$CopyTo' (copied from '$Path')."
Copy-Item $Path $CopyTo -Force -ErrorAction SilentlyContinue | Out-Null
$Path = "$CopyTo\$($Path | Split-Path -Leaf)"
Expand Down
2 changes: 1 addition & 1 deletion Import-Package/src/Resolve-CachedPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function Resolve-CachedPackage {
$PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent,
($VerbosePreference -ne 'SilentlyContinue')
) -contains $true ){
Write-Verbose "[Import-Package:Preparation] Installed $( $Options.Name ) $( $Options.Version ) from:"
Write-Verbose "[Import-Package:Preparation] Installing $( $Options.Name ) $( $Options.Version ) from:"
Write-Host "-" $url -ForegroundColor Cyan
Write-Host
}
Expand Down

0 comments on commit f613e23

Please sign in to comment.