Skip to content

Commit

Permalink
fix: display requirements only when present
Browse files Browse the repository at this point in the history
  • Loading branch information
jegj committed Jan 26, 2024
1 parent d0ea3b3 commit 1df266e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/presenter/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ function updateTable (name, tier, confidence, gameData, table, screen) {
}

if (gameData.requirements) {
if (gameData?.requirements?.minimum) {
if (gameData?.requirements?.minimum && Object.keys(gameData?.requirements?.minimum).length > 0) {
data.push(
['{bold}{yellow-fg}Minimum Requirements{/yellow-fg}{/bold}', '-']
)
data = generateRequirementsEntries(gameData?.requirements?.minimum, data)
}

if (gameData?.requirements?.recommended) {
if (gameData?.requirements?.recommended && Object.keys(gameData?.requirements?.recommended).length > 0) {
data.push(
['{bold}{green-fg}Recommended Requirements{/green-fg}{/bold}', '-']
)
Expand Down
6 changes: 6 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import fs from 'fs'

export function isValidUrl (url) {
const furl = new URL(url)
if (furl.protocol !== 'http:' && furl.protocol !== 'https:') {
Expand All @@ -9,3 +11,7 @@ export function isValidGameName (gameName) {
if (!(typeof gameName === 'string' || gameName instanceof String) || !gameName) { throw new Error('Invalid game name') }
return gameName
}

export function debugGameData (gameData) {
fs.writeFileSync('/tmp/debug.json', JSON.stringify(gameData))
}

0 comments on commit 1df266e

Please sign in to comment.