зеркало из https://github.com/mozilla/tsci.git
Issue #129 - Read config using filesystem APIs rather than require
This commit is contained in:
Родитель
9bdab9fab1
Коммит
afa4ac9843
13
helpers.js
13
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"
|
||||
|
|
5
index.js
5
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 || "";
|
||||
|
|
Загрузка…
Ссылка в новой задаче