Skip to content

Commit

Permalink
Support for settings on Linux and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
vedantmgoyal9 authored Oct 5, 2021
1 parent cbf1f38 commit dc8a128
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Tools/YamlCreate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ if ($help) {
exit
}

# Set settings directory on basis of Operating System
# $IsWindows, $IsLinux and $IsMacOS were introduced in PowerShell 6.0+
# $env:OS for older versions of PowerShell
if ($IsWindows -or $env:OS) {
$script:SettingsPath = Join-Path $env:LOCALAPPDATA -ChildPath 'YamlCreate' # On Windows
} else {
$script:SettingsPath = Join-Path $env:HOME -ChildPath 'YamlCreate' # On Linux and macOS
}
# Check for settings directory and create it if none exists
$script:SettingsPath = Join-Path $env:LOCALAPPDATA -ChildPath 'YamlCreate'
if (!(Test-Path $script:SettingsPath)) { New-Item -ItemType 'Directory' -Force -Path $script:SettingsPath | Out-Null }
# Check for settings file and create it if none exists
$script:SettingsPath = $(Join-Path $script:SettingsPath -ChildPath 'Settings.yaml')
Expand Down

0 comments on commit dc8a128

Please sign in to comment.