|
6 | 6 |
|
7 | 7 | # The location of the file that we'll store any settings that can/should roam with the user.
|
8 | 8 | [string] $script:configurationFilePath = [System.IO.Path]::Combine(
|
9 |
| - [Environment]::GetFolderPath('ApplicationData'), |
| 9 | + [System.Environment]::GetFolderPath('ApplicationData'), |
10 | 10 | 'Microsoft',
|
11 | 11 | 'PowerShellForGitHub',
|
12 | 12 | 'config.json')
|
13 | 13 |
|
14 | 14 | # The location of the file that we'll store the Access Token SecureString
|
15 | 15 | # which cannot/should not roam with the user.
|
16 | 16 | [string] $script:accessTokenFilePath = [System.IO.Path]::Combine(
|
17 |
| - [Environment]::GetFolderPath('LocalApplicationData'), |
| 17 | + [System.Environment]::GetFolderPath('LocalApplicationData'), |
18 | 18 | 'Microsoft',
|
19 | 19 | 'PowerShellForGitHub',
|
20 | 20 | 'accessToken.txt')
|
@@ -650,10 +650,16 @@ function Import-GitHubConfiguration
|
650 | 650 | # Create a configuration object with all the default values. We can then update the values
|
651 | 651 | # with any that we find on disk.
|
652 | 652 | $logPath = [String]::Empty
|
| 653 | + $logName = 'PowerShellForGitHub.log' |
653 | 654 | $documentsFolder = [System.Environment]::GetFolderPath('MyDocuments')
|
654 |
| - if (-not [System.String]::IsNullOrEmpty($documentsFolder)) |
| 655 | + $logToLocalAppDataFolder = [System.String]::IsNullOrEmpty($documentsFolder) |
| 656 | + if ($logToLocalAppDataFolder) |
655 | 657 | {
|
656 |
| - $logPath = Join-Path -Path $documentsFolder -ChildPath 'PowerShellForGitHub.log' |
| 658 | + $logPath = Join-Path -Path ([System.Environment]::GetFolderPath('LocalApplicationData')) -ChildPath $logName |
| 659 | + } |
| 660 | + else |
| 661 | + { |
| 662 | + $logPath = Join-Path -Path $documentsFolder -ChildPath $logName |
657 | 663 | }
|
658 | 664 |
|
659 | 665 | $config = [PSCustomObject]@{
|
@@ -697,6 +703,17 @@ function Import-GitHubConfiguration
|
697 | 703 | $config.$name = Resolve-PropertyValue -InputObject $jsonObject -Name $name -Type $type -DefaultValue $config.$name
|
698 | 704 | }
|
699 | 705 |
|
| 706 | + # Let the user know when we had to revert to using the LocalApplicationData folder for the |
| 707 | + # log location (if they haven't already changed its path in their local config). |
| 708 | + $configuredLogPath = $config.logPath |
| 709 | + if ($logToLocalAppDataFolder -and ($logPath -eq $configuredLogPath)) |
| 710 | + { |
| 711 | + # Limited instance where we write the warning directly instead of using Write-Log, since |
| 712 | + # Write-Log won't yet be configured. |
| 713 | + $message = "Storing log at non-default location: [$logPath] (no user profile path was found). You can change this location by calling Set-GitHubConfiguration -LogPath <desiredPathToLogFile>" |
| 714 | + Write-Verbose -Message $message |
| 715 | + } |
| 716 | + |
700 | 717 | return $config
|
701 | 718 | }
|
702 | 719 |
|
|
0 commit comments