Skip to content

Commit

Permalink
Consolidated platforms into array
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkelM committed Jan 2, 2023
1 parent 2a1f725 commit d2ead66
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 60 deletions.
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,13 @@ The language to use when fetching game properties. Properties such as the game d
</details>

<details>
<summary><code>fetchConsole</code></summary>
<summary><code>platformsToFetch</code></summary>

Whether or not to fetch games available for console Game Pass.
Which platforms to fetch games for, any of "console", "pc" and "eaPlay".

| Type | Default value | Possible values | Required |
| --- | --- | --- | --- |
| `boolean` | `true` | `true` or `false` | No (but at least one of `fetchConsole`, `fetchPC` or `fetchEAPlay`). |
</details>

<details>
<summary><code>fetchPC</code></summary>

Whether or not to fetch games available for PC Game Pass.

| Type | Default value | Possible values | Required |
| --- | --- | --- | --- |
| `boolean` | `true` | `true` or `false` | No (but at least one of `fetchConsole`, `fetchPC` or `fetchEAPlay`). |
</details>

<details>
<summary><code>fetchEAPlay</code></summary>

Whether or not to fetch games available through EA Play.

| Type | Default value | Possible values | Required |
| --- | --- | --- | --- |
| `boolean` | `true` | `true` or `false` | No (but at least one of `fetchConsole`, `fetchPC` or `fetchEAPlay`). |
| `array` | `["console", "pc", "eaPlay"]` | `"console"`, `"pc"`, `"eaPlay"` | Yes, at least one platform. |
</details>

<details>
Expand Down
8 changes: 5 additions & 3 deletions config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"US"
],
"language": "en-us",
"fetchConsole": true,
"fetchPC": true,
"fetchEAPlay": true,
"platformsToFetch": [
"console",
"pc",
"eaPlay"
],
"outputFormat": "array",
"treatEmptyStringsAsNull": true,
"keepCompleteProperties": false,
Expand Down
51 changes: 20 additions & 31 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,25 @@
"ar-sa"
]
},
"fetchConsole": {
"description": "Whether or not to fetch games available for console Game Pass.",
"type": "boolean",
"default": true
},
"fetchPC": {
"description": "Whether or not to fetch games available for PC Game Pass.",
"type": "boolean",
"default": true
},
"fetchEAPlay": {
"description": "Whether or not to fetch games available through EA Play.",
"type": "boolean",
"default": true
"platformsToFetch": {
"description": "Which platforms to fetch games for, any of \"console\", \"pc\" and \"eaPlay\".",
"type": "array",
"default": [
"console",
"pc",
"eaPlay"
],
"items": {
"type": "string",
"enum": [
"console",
"pc",
"eaPlay"
]
},
"minItems": 1,
"additionalItems": false,
"uniqueItems": true
},
"outputFormat": {
"description": "What kind of format the resulting JSON should use for the cleaned game properties.",
Expand Down Expand Up @@ -661,26 +666,10 @@
"minProperties": 1
}
},
"anyOf": [
{
"required": [
"fetchConsole"
]
},
{
"required": [
"fetchPC"
]
},
{
"required": [
"fetchEAPlay"
]
}
],
"required": [
"markets",
"language",
"platformsToFetch",
"outputFormat",
"includedProperties"
],
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ async function main() {
// Fetch Game Pass game ID's and properties for each pass type and market specified in the configuration
// We do this in parallel to speed up the process
for (const market of CONFIG.markets) {
if (CONFIG.fetchConsole) {
if (CONFIG.platformsToFetch.includes("console")) {
const consoleFormattedProperties = runScriptForPassTypeAndMarket("console", market);
}
if (CONFIG.fetchPC) {
if (CONFIG.platformsToFetch.includes("pc")) {
const pcFormattedProperties = runScriptForPassTypeAndMarket("pc", market);
}
if (CONFIG.fetchEAPlay) {
if (CONFIG.platformsToFetch.includes("eaPlay")) {
const eaPlayFormattedProperties = runScriptForPassTypeAndMarket("eaPlay", market);
}
}
Expand Down

0 comments on commit d2ead66

Please sign in to comment.