Skip to content

Commit ee39730

Browse files
committed
Fix default backup directory method
1 parent 103e987 commit ee39730

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

backup_github_repositories.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<#
1+
#Requires -Version 5.0
22

3+
<#
34
.SYNOPSIS
45
Automatically backups all remote GitHub repositories.
56
@@ -26,8 +27,8 @@ Overrides the default backup directory.
2627
2728
.EXAMPLE
2829
.\backup_github_repositories.ps1 -backupDirectory "C:\myBackupDirectory"
29-
3030
#>
31+
3132
[CmdletBinding()]
3233
Param (
3334

@@ -45,9 +46,16 @@ Param (
4546

4647
[string]$organisationName,
4748

48-
[string]$backupDirectory = $(Join-Path -Path $PSScriptRoot -ChildPath $(Get-Date -UFormat "%Y-%m-%d"))
49+
[string]$backupDirectory
4950
)
5051

52+
# Default the backup directory to './YYYY-MM-DD'. This can
53+
# not be done in the Param section because $PSScriptRoot
54+
# will not be resolved if this script gets invoked from cmd.
55+
if (!$backupDirectory) {
56+
$backupDirectory = $(Join-Path -Path "$PSScriptRoot" -ChildPath $(Get-Date -UFormat "%Y-%m-%d"))
57+
}
58+
5159
#
5260
# Clone a remote GitHub repository into a local directory.
5361
#

0 commit comments

Comments
 (0)