diff --git a/helpers.js b/helpers.js index 529a280..e87e398 100644 --- a/helpers.js +++ b/helpers.js @@ -1,9 +1,10 @@ -const config = require("./config.json"); const fetch = require("node-fetch"); -const fs = require("fs").promises; +const fs = require("fs"); const retry = require("promise-fn-retry"); const util = require("util"); +const config = JSON.parse(fs.readFileSync("config.json", { encoding: "utf8" })); + /** * Retry a bugzilla query. * @param {String} query The specified bugzilla query @@ -241,8 +242,12 @@ async function recordCurrentDoc(currentDocId) { config.startingSpreadsheetId = currentDocId; Promise.all([ - fs.writeFile("config.json", JSON.stringify(config, null, 2), "utf8"), - fs.writeFile( + fs.promises.writeFile( + "config.json", + JSON.stringify(config, null, 2), + "utf8" + ), + fs.promises.writeFile( `${config.currentDocPath}/currentDoc.json`, JSON.stringify({ currentDoc: currentDocId }), "utf8" diff --git a/index.js b/index.js index e4321be..aba208a 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const { google } = require("googleapis"); const bugs = require("./bugs"); +const fs = require("fs"); const helpers = require("./helpers"); const spreadsheet = require("./spreadsheet"); const tranco = require("./tranco"); @@ -7,7 +8,9 @@ const tranco = require("./tranco"); const argv = process.argv.slice(2); const main = async () => { - const config = require("./config.json"); + const config = JSON.parse( + await fs.promises.readFile("config.json", { encoding: "utf8" }) + ); const LIST_SIZE = config.listSize || 500; const LIST_DIR = config.listDir || "data/"; const bugzillaKey = config.bugzillaKey || "";