Update raw-api.js

This commit is contained in:
William Harrison authored and GitHub committed 2023-03-11 18:15:12 +08:00
1 parent 43c243d667
commit 821cb3fb77
1 file changed
+10 -10
+10 -10
View File
@@ -6,10 +6,10 @@ const directoryPath = path.join(__dirname, "../domains");
let combinedArray = [];
fs.readdir(directoryPath, function (err, files) {
if(err) throw err;
if (err) throw err;
function removeValue(value, index, arr) {
if(value === "reserved") {
if (value === "reserved") {
arr.splice(index, 1);
return true;
}
@@ -23,21 +23,21 @@ fs.readdir(directoryPath, function (err, files) {
const filePath = path.join(directoryPath, file);
fs.readFile(filePath, "utf8", (err, data) => {
if(err) throw err;
if (err) throw err;
const dataArray = [JSON.parse(data)];
for(const item of dataArray) {
for (const item of dataArray) {
item.owner.email = item.owner.email.replace(/@/, " (at) ");
}
combinedArray = combinedArray.concat(dataArray);
if(combinedArray.length === files.length) {
if (combinedArray.length === files.length) {
fs.writeFile("raw-api/index.json", JSON.stringify(combinedArray), (err) => {
if(err) throw err;
})
if (err) throw err;
});
}
})
})
})
});
});
});