Skip to content

Commit c79c3fa

Browse files
committed
Move fetching of compat data to its dedicated function
1 parent 778428b commit c79c3fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

update_remote_settings_records.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
import fetch from "node-fetch";
1818
import btoa from "btoa";
1919

20-
// See https://github.com/mdn/browser-compat-data.
21-
const response = await fetch("https://unpkg.com/@mdn/browser-compat-data/data.json");
22-
const compatData = await response.json();
23-
2420
const SUCCESS_RET_VALUE = 0;
2521
const FAILURE_RET_VALUE = 1;
2622
const VALID_ENVIRONMENTS = ["dev", "stage", "prod"];
@@ -73,7 +69,7 @@ async function update() {
7369
const records = await getRSRecords();
7470
const operations = { added: [], updated: [], removed: [] };
7571

76-
const browsersMdn = getFlatBrowsersMdnData();
72+
const browsersMdn = await getFlatBrowsersMdnData();
7773

7874
for (const browserMdn of browsersMdn) {
7975
const rsRecord = records.find(
@@ -314,7 +310,11 @@ async function approveChanges() {
314310
}
315311
}
316312

317-
function getFlatBrowsersMdnData() {
313+
async function getFlatBrowsersMdnData() {
314+
// See https://github.com/mdn/browser-compat-data.
315+
const response = await fetch("https://unpkg.com/@mdn/browser-compat-data/data.json");
316+
const compatData = await response.json();
317+
318318
const browsers = [];
319319
for (const [browserid, browserInfo] of Object.entries(compatData.browsers)) {
320320
for (const [releaseNumber, releaseInfo] of Object.entries(

0 commit comments

Comments
 (0)