Skip to content

Commit

Permalink
Extract to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed Aug 18, 2019
1 parent 12d2c45 commit f5a48ef
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/ManifestHelpers.psm1
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
function Resolve-LocalScopeVariable {
<#
.SYNOPSIS
Get correct value for variable defined in different / unaccessible scope from module.
#>
param([Parameter(Mandatory = $true, ValueFromPipeline = $true)][String] $Variable)

return $PSCmdlet.SessionState.PSVariable.GetValue($Variable)
}

function Initialize-Variables {
<#
.SYNOPSIS
Expand All @@ -6,12 +16,12 @@ function Initialize-Variables {
#>
# Do not create variable when there are already defined.
if (-not $dir) {
$script:dir = $PSCmdlet.SessionState.PSVariable.GetValue('dir')
$script:persist_dir = $PSCmdlet.SessionState.PSVariable.GetValue('persist_dir')
$script:fname = $PSCmdlet.SessionState.PSVariable.GetValue('fname')
$script:version = $PSCmdlet.SessionState.PSVariable.GetValue('version')
$script:global = $PSCmdlet.SessionState.PSVariable.GetValue('global')
$script:manifest = $PSCmdlet.SessionState.PSVariable.GetValue('manifest')
$script:dir = Resolve-LocalScopeVariable 'dir'
$script:persist_dir = Resolve-LocalScopeVariable 'persist_dir'
$script:fname = Resolve-LocalScopeVariable 'fname'
$script:version = Resolve-LocalScopeVariable 'version'
$script:global = Resolve-LocalScopeVariable 'global'
$script:manifest = Resolve-LocalScopeVariable 'manifest'
}
}

Expand Down

0 comments on commit f5a48ef

Please sign in to comment.