Skip to content

Commit

Permalink
Use localized strings for package upgrade parsing (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbergstrom authored May 13, 2022
1 parent f744d76 commit 0d3f63a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2022-05-13
### Fixed
- Package upgrade list functionality now correctly supports non-EN-US localities

## [0.3.0] - 2022-05-12
### Added
- Ability to return a list of packages that qualify for updates
Expand Down
5 changes: 3 additions & 2 deletions src/Cobalt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ $i18nHandlerHelper = {
('ShowVersion','Version'),
('GetManifestResultVersionNotFound','No version found matching:'),
('InstallerFailedWithCode','Installer failed with exit code:'),
('UninstallFailedWithCode','Uninstall failed with exit code:')
('UninstallFailedWithCode','Uninstall failed with exit code:'),
('AvailableUpgrades','upgrades available.')
) | ForEach-Object {[pscustomobject]@{name = $_[0]; value = $_[1]}}
}) | ForEach-Object {
# Convert the array into a hashtable
Expand Down Expand Up @@ -69,7 +70,7 @@ $GetPackageOutputHandler = {
# Only attempt to parse output if it contains a 'version' column
if ($versionIndex -ne -1) {
# The -replace cleans up errant characters that come from WinGet's poor treatment of truncated columnar output
($output | Select-String -Pattern 'upgrades available.','--include-unknown' -NotMatch) -replace '[^i\p{IsBasicLatin}]',' ' | Select-Object -Skip ($headerLine+2) | ForEach-Object {
($output | Select-String -Pattern $languageData.AvailableUpgrades,'--include-unknown' -NotMatch) -replace '[^i\p{IsBasicLatin}]',' ' | Select-Object -Skip ($headerLine+2) | ForEach-Object {
Remove-Variable -Name 'package' -ErrorAction SilentlyContinue

$package = [ordered]@{
Expand Down
2 changes: 1 addition & 1 deletion src/Cobalt.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'Cobalt.psm1'
ModuleVersion = '0.3.0'
ModuleVersion = '0.3.1'
GUID = '9f295092-e7fd-4c52-b41e-3c5b0612fa52'
Author = 'Ethan Bergstrom'
Copyright = '2021'
Expand Down

0 comments on commit 0d3f63a

Please sign in to comment.