diff --git a/data/templates/Markdown.md b/data/templates/New.md similarity index 100% rename from data/templates/Markdown.md rename to data/templates/New.md diff --git a/scripts/new-markdown-file.ps1 b/scripts/new-markdown-file.ps1 index a537d114..65872a29 100755 --- a/scripts/new-markdown-file.ps1 +++ b/scripts/new-markdown-file.ps1 @@ -1,13 +1,13 @@ <# .SYNOPSIS - Creates a new Markdown file + Creates a Markdown file .DESCRIPTION - This PowerShell script creates a new Markdown file from template file at: ../data/templates/Markdown.md. + This PowerShell script creates a new Markdown file from template: ../data/templates/New.md. .PARAMETER path Specifies the path and new filename (README.md by default) .EXAMPLE PS> ./new-markdown-file.ps1 - ✅ New file 'README.md' created from template 'Markdown.md'. + ✅ New 'README.md' created (from data/templates/New.md). .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -17,11 +17,13 @@ param([string]$path = "README.md") try { - $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/Markdown.md" + if (Test-Path "$path" -pathType leaf)) { throw "File '$path' is already existing" } + + $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/New.md" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" } - "✅ New file '$path' created from template 'Markdown.md'." + "✅ New '$path' created (from data/templates/New.md)." exit 0 # success } catch { "⚠️ Error: $($Error[0])" diff --git a/scripts/new-powershell-script.ps1 b/scripts/new-powershell-script.ps1 index 83cb0a4e..658d4626 100755 --- a/scripts/new-powershell-script.ps1 +++ b/scripts/new-powershell-script.ps1 @@ -17,6 +17,8 @@ param([string]$path = "bot.ps1") try { + if (Test-Path "$path" -pathType leaf)) { throw "File '$path' is already existing" } + $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/New.ps1" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy to: $path" } diff --git a/scripts/new-text-file.ps1 b/scripts/new-text-file.ps1 index 48c123d5..2d23e7cf 100755 --- a/scripts/new-text-file.ps1 +++ b/scripts/new-text-file.ps1 @@ -17,6 +17,8 @@ param([string]$path = "README.txt") try { + if (Test-Path "$path" -pathType leaf)) { throw "File '$path' is already existing" } + $pathToTemplate = Resolve-Path "$PSScriptRoot/../data/templates/New.txt" Copy-Item $pathToTemplate "$path" if ($lastExitCode -ne 0) { throw "Can't copy template to: $path" }