Skip to content

Commit f02af37

Browse files
committed
🐛 Import-CharConstants.ps1 should not throw errors when run again
- resolves brianary#90
1 parent aeba7f1 commit f02af37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Import-CharConstants.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ Begin
4646
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)][Alias('Key')][string] $Alias,
4747
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)][Alias('Value')][string] $CharacterName
4848
)
49+
$name = $Alias.Trim(':')
4950
$char = $CharacterName -eq 'NL' ? [Environment]::NewLine : (Get-UnicodeByName.ps1 -Name $CharacterName -AsEmoji:$AsEmoji)
50-
Set-Variable -Name ($Alias.Trim(':')) -Value $char -Scope $level -Option Constant -Description $CharacterName
51+
$existing = Get-Variable -Name $name -Scope $level -ErrorAction Ignore
52+
if($existing -and ($existing.Options -eq 'Constant') -and ($existing.Value -eq $char)) {return}
53+
Set-Variable -Name $name -Value $char -Scope $level -Option Constant -Description $CharacterName
5154
}
5255
}
5356
Process

0 commit comments

Comments
 (0)