Skip to content

Commit

Permalink
Merge pull request #116 from PlagueHO/master and !Deploy
Browse files Browse the repository at this point in the history
Changed PSYaml support module to use OS specific Temp folder as Default - Fixes #113
  • Loading branch information
RamblingCookieMonster committed Sep 23, 2018
2 parents 8194813 + 665f35c commit 072a1bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions PSDeploy/Private/PSYaml/Private/Get-TempPath.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<#
.SYNOPSIS
Return the OS specific temp folder path.
#>
function Get-TempPath() {
if($ENV:Temp) {
# Windows Temp Folder Location
return $ENV:Temp
}
elseif ($env:TMPDIR) {
# macOS Temp Folder Location
return $ENV:TMPDIR
}
else {
# Linux Temp Folder Location
return '/tmp'
}
}
2 changes: 1 addition & 1 deletion PSDeploy/Private/PSYaml/Private/Shadow-Copy.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Shadow-Copy($file, $shadowPath = "$($env:TEMP)\poweryaml\shadow") {
function Shadow-Copy($file, $shadowPath = (Join-Path -Path (Get-TempPath) -ChildPath 'poweryaml\shadow')) {

if(!(Test-Path -Path Variable:\IsWindows) -or $IsWindows) {
if (-not (Test-Path $shadowPath ) ) {
Expand Down
6 changes: 3 additions & 3 deletions PSDeploy/Private/PSYaml/Private/YamlDotNet-Integration.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Load-YamlDotNetLibraries([string] $dllPath, $shadowPath = "$($env:TEMP)\poweryaml\shadow") {
function Load-YamlDotNetLibraries([string] $dllPath, $shadowPath = (Join-Path -Path (Get-TempPath) -ChildPath 'poweryaml\shadow')) {
gci $dllPath | % {
$shadow = Shadow-Copy -File $_.FullName -ShadowPath $shadowPath
Add-Type -Path $Shadow
Expand Down Expand Up @@ -42,14 +42,14 @@ function Convert-YamlScalarNodeToValue {

function Convert-YamlMappingNodeToHash {
param($node, $As)

$hash = @{}

if($ModernPS -and $As -eq 'Object')
{
$hash = [ordered]@{}
}

$yamlNodes = $node.Children

foreach($key in $yamlNodes.Keys)
Expand Down

0 comments on commit 072a1bf

Please sign in to comment.