Skip to content

Commit eb5a7c0

Browse files
committed
Add task to update glyphs from nerdfonts.com
1 parent 5892640 commit eb5a7c0

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Terminal-Icons/Data/glyphs.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
@{
1+
@{
32
'nf-custom-c' = ''
43
'nf-custom-cpp' = ''
54
'nf-custom-electron' = ''

psakeFile.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ task default -depends Test
1313

1414
task Pester -FromModule PowerShellBuild -Version '0.6.1' -preaction {Remove-Module Terminal-Icons -ErrorAction SilentlyContinue}
1515

16+
task UpdateGlyphs {
17+
Import-Module PowerHtml
18+
19+
$cheatsheet = 'https://www.nerdfonts.com/cheat-sheet'
20+
$parsedHtml = Invoke-WebRequest $cheatsheet | ConvertFrom-Html
21+
$glyphs = $parsedHtml.SelectNodes("//div[@class='class-name']").ForEach({
22+
[pscustomobject]@{
23+
name = $_.InnerText
24+
codePoint = $_.NextSibling[0].InnerText
25+
}
26+
})
27+
28+
$sb = [Text.StringBuilder]::new()
29+
$sb.AppendLine('@{') > $null
30+
$glyphs.ForEach({
31+
$icon = [char][int]"0x$($_.codePoint)"
32+
$sb.AppendFormat(" '{0}' = '{1}'`n", $_.Name, $icon ) > $null
33+
})
34+
$sb.AppendLine('}') > $null
35+
36+
$now = [int][double]::Parse((Get-Date -UFormat %s))
37+
$fileName = "$PSScriptRoot/Terminal-Icons/Data/glyphs_$now.ps1"
38+
$sb.ToString().Trim() | Out-File $fileName -Encoding utf8
39+
40+
} -description 'Create a list of glyphs, sourced from nerdfonts.com'
41+
1642
task InstallAct {
1743
if (-not (Get-Command -Name act -CommandType Application -ErrorAction SilentlyContinue)) {
1844
if ($IsWindows) {

requirements.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313
}
1414
platyPS = '0.14.1'
15+
PowerHtml = 'latest'
1516
PowerShellBuild = @{
1617
RequiredVersion = '0.6.1'
1718
}

0 commit comments

Comments
 (0)