diff --git a/sync-skills.ps1 b/sync-skills.ps1 index de6e170..8df0fa3 100644 --- a/sync-skills.ps1 +++ b/sync-skills.ps1 @@ -1,11 +1,17 @@ [CmdletBinding()] param( [string] $SourceRoot = 'C:\Users\dkucinski\.scout\m-skills', - [string] $RepositoryRoot = $PSScriptRoot + [string] $RepositoryRoot ) $ErrorActionPreference = 'Stop' +# $PSScriptRoot is empty when the script is launched as `powershell -File ` +# (Windows PowerShell 5.1), which would make the Resolve-Path below fail on an empty string. +if ([string]::IsNullOrWhiteSpace($RepositoryRoot)) { + $RepositoryRoot = if ($PSScriptRoot) { $PSScriptRoot } else { Split-Path -Parent $MyInvocation.MyCommand.Path } +} + $repositoryRoot = (Resolve-Path -LiteralPath $RepositoryRoot).Path $sourceRoot = (Resolve-Path -LiteralPath $SourceRoot).Path $logDirectory = Join-Path $repositoryRoot 'logs'