Skip to content

Commit

Permalink
Allow external settings definition
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Aug 31, 2020
1 parent 98c93bb commit 268bf38
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/Javinizer/Public/Javinizer.ps1
Expand Up @@ -245,14 +245,13 @@ function Javinizer {
[Parameter(ParameterSetName = 'Info')]
[Switch]$Jav321,
[Parameter(ParameterSetName = 'Path', Position = 0)]
[Alias('p')]
[System.IO.DirectoryInfo]$Path,
[Parameter(ParameterSetName = 'Path', Position = 1)]
[Alias('d')]
[System.IO.DirectoryInfo]$DestinationPath,
[Parameter(ParameterSetName = 'Path', Position = 2)]
[PSObject]$Settings,
[Parameter(ParameterSetName = 'Path')]
[Alias('u')]
[Array]$Url,
[PSObject]$Url,
[Parameter(ParameterSetName = 'Path')]
[Alias('m')]
[Switch]$Multi,
Expand All @@ -261,10 +260,6 @@ function Javinizer {
[Switch]$Recurse,
[Parameter(ParameterSetName = 'Path')]
[Switch]$Force,
[Parameter(ParameterSetName = 'Path')]
[PSObject]$Settings,
[Parameter(ParameterSetName = 'Path')]
[String]$ImportSettings,
[Parameter(ParameterSetName = 'Help')]
[Alias('h')]
[Switch]$Help,
Expand Down Expand Up @@ -292,7 +287,13 @@ function Javinizer {
)

begin {
$urlLocation = @()
if (-not $PSBoundParameters.ContainsKey('Confirm')) {
$ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference')
}

if (-not $PSBoundParameters.ContainsKey('WhatIf')) {
$WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference')
}

if (!($Multi.IsPresent -or $GetThumbs.IsPresent -or $UpdateThumbs.IsPresent)) {
$ProgressPreference = 'SilentlyContinue'
Expand Down Expand Up @@ -332,12 +333,21 @@ function Javinizer {
}

process {
$settingsPath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'jvSettings.json'
if ($Settings) {
$settingsPath = $Settings
} else {
$settingsPath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'jvSettings.json'
}

$Settings = Get-Content -LiteralPath $settingsPath | ConvertFrom-Json -Depth 32

if ($Settings.'admin.log.path' -eq '') {
$logPath = Join-Path -Path ((Get-Item $PSScriptRoot).Parent) -ChildPath 'jvLog.log'
} else {
if (!(Test-Path -LiteralPath $Settings.'admin.log.path' -PathType Leaf)) {
New-Item -LiteralPath $Settings.'admin.log.path'
}

$logPath = $Settings.'admin.log.path'
}

Expand Down

0 comments on commit 268bf38

Please sign in to comment.