From ce91b937454c0f04030b292dd5c16f88f7e5ccaf Mon Sep 17 00:00:00 2001 From: William Harrison Date: Sat, 5 Nov 2022 11:14:06 +0800 Subject: [PATCH] fix formatting --- scripts/addRecords.js | 12 ++++++------ utils/checkInfo.js | 10 +++++----- utils/checkRecords.js | 7 ++++--- utils/getJSON.js | 12 ++++++------ 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/scripts/addRecords.js b/scripts/addRecords.js index 0a8b10f..4a3aa6c 100644 --- a/scripts/addRecords.js +++ b/scripts/addRecords.js @@ -1,5 +1,5 @@ -const fetch = require("node-fetch"); -const getJSON = require("../utils/getJSON.js"); +const fetch = require('node-fetch'); +const getJSON = require('../utils/getJSON.js'); const data = getJSON(process.env.FILES); async function addRecord(type, name, value) { @@ -11,11 +11,11 @@ async function addRecord(type, name, value) { (async () => { try { - if(!data) return; + if (!data) return; const records = Object.keys(data.target); - for(const i in records) { + for (const i in records) { recordType = records[i]; name = data.target[recordType].name; value = data.target[recordType].value; @@ -23,8 +23,8 @@ async function addRecord(type, name, value) { const res = await addRecord(recordType, name, value); console.log(res); } - } catch (e) { - console.log("Failed to add records."); + } catch(e) { + console.log('Failed to add records.'); console.log(e); } })(); diff --git a/utils/checkInfo.js b/utils/checkInfo.js index 2d03691..d2fd215 100644 --- a/utils/checkInfo.js +++ b/utils/checkInfo.js @@ -1,5 +1,5 @@ -const fetch = require("node-fetch"); -const core = require("@actions/core"); +const fetch = require('node-fetch'); +const core = require('@actions/core'); async function checkEmail(email) { console.log(`Checking: ${email}`); @@ -7,15 +7,15 @@ async function checkEmail(email) { const url = `https://api.is-a-good.dev/email-check?key=6lPyUV2dX8&email=${encodeURIComponent(email)}`; const options = { - method: "GET" + method: 'GET' } const res = await fetch(url, options).then(res => res.json()); console.log(res); - core.setOutput("infoReason", res.reason); + core.setOutput('infoReason', res.reason); - if(res.data.valid) return true; + if (res.data.valid) return true; return false; } diff --git a/utils/checkRecords.js b/utils/checkRecords.js index 61d8ed1..ace3dbe 100644 --- a/utils/checkRecords.js +++ b/utils/checkRecords.js @@ -1,15 +1,16 @@ -const { checkIfValidIP, checkIfValidFQDN } = require("./utils.js"); +const { checkIfValidIP, checkIfValidFQDN } = require('./utils.js'); function checkRecords(data) { const recordType = Object.keys(data.target)[0]; - if(recordType.toLowerCase() === "a") { + if (recordType.toLowerCase() === 'a') { return checkIfValidIP(data.target[recordType].value); } - if(recordType.toLowerCase() === "cname") { + if (recordType.toLowerCase() === 'cname') { return checkIfValidFQDN(data.target[recordType].value); } + return false; } diff --git a/utils/getJSON.js b/utils/getJSON.js index c6de376..c096a67 100644 --- a/utils/getJSON.js +++ b/utils/getJSON.js @@ -1,5 +1,5 @@ -const fs = require("fs"); -const invalidDomains = require("./invalid-domains.json"); +const fs = require('fs'); +const invalidDomains = require('./invalid-domains.json'); function getFileExtension(filename) { return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined; @@ -9,15 +9,15 @@ function getJSON(file, filename) { const path = `${process.env.actions_path}/${file}`; // File path. const ext = getFileExtension(file); - if(!ext) return false; // If no file extension, return. - if(ext != "json") return false; // If file extension is not ".json" return. + if (!ext) return false; // If no file extension, return. + if (ext != 'json') return false; // If file extension is not '.json' return. invalidDomains.forEach(domain => { - if(filename === domain) return false; + if (filename === domain) return false; }) try { - if(fs.existsSync(path)) { // Check if file exists in domain directory + if (fs.existsSync(path)) { // Check if file exists in domain directory // It exists const rawdata = fs.readFileSync(path); // Read the file const data = JSON.parse(rawdata); // Parse it