From dc8a12854d7e8d33bff6614047d6d929c9d55b68 Mon Sep 17 00:00:00 2001 From: Vedant Mohan Goyal <83997633+vedantmgoyal2009@users.noreply.github.com> Date: Tue, 5 Oct 2021 23:02:26 +0530 Subject: [PATCH] Support for settings on Linux and macOS --- Tools/YamlCreate.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tools/YamlCreate.ps1 b/Tools/YamlCreate.ps1 index d590132c14c98..e98fd590deeb0 100644 --- a/Tools/YamlCreate.ps1 +++ b/Tools/YamlCreate.ps1 @@ -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')