fix code style

This commit is contained in:
Karol Wypchlo 2021-01-26 17:00:13 +01:00
parent 8e0160bfb7
commit 2f1ec00e29
2 changed files with 22 additions and 18 deletions

View File

@ -1,6 +1,6 @@
const fs = require("fs"); const fs = require("fs");
const superagent = require("superagent"); const superagent = require("superagent");
const tmp = require('tmp'); const tmp = require("tmp");
const { StatusCodes } = require("http-status-codes"); const { StatusCodes } = require("http-status-codes");
const { calculateElapsedTime, getResponseContent } = require("../utils"); const { calculateElapsedTime, getResponseContent } = require("../utils");
@ -8,7 +8,7 @@ const { calculateElapsedTime, getResponseContent } = require("../utils");
async function uploadCheck(done) { async function uploadCheck(done) {
const time = process.hrtime(); const time = process.hrtime();
const file = tmp.fileSync(); const file = tmp.fileSync();
fs.writeSync(file.fd, Buffer.from(new Date())); // write current date to temp file fs.writeSync(file.fd, Buffer.from(new Date())); // write current date to temp file
superagent superagent

View File

@ -1,21 +1,25 @@
require('yargs/yargs')(process.argv.slice(2)) require("yargs/yargs")(process.argv.slice(2)).command(
.command('$0 <type>', 'Skynet portal health checks', (yargs) => { "$0 <type>",
yargs.positional('type', { "Skynet portal health checks",
describe: 'Type of checks to run', (yargs) => {
type: 'string', yargs
choices: ["critical", "verbose"] .positional("type", {
}) describe: "Type of checks to run",
.option("portal-url", { type: "string",
choices: ["critical", "verbose"],
})
.option("portal-url", {
describe: "Skynet portal url", describe: "Skynet portal url",
default: process.env.PORTAL_URL || "https://siasky.net", default: process.env.PORTAL_URL || "https://siasky.net",
type: "string", type: "string",
}) })
.option("state-dir", { .option("state-dir", {
describe: "State directory", describe: "State directory",
default: process.env.STATE_DIR || "state", default: process.env.STATE_DIR || "state",
type: "string", type: "string",
}) });
}, async ({ type, portalUrl, stateDir }) => { },
async ({ type, portalUrl, stateDir }) => {
process.env.PORTAL_URL = portalUrl; process.env.PORTAL_URL = portalUrl;
process.env.STATE_DIR = stateDir; process.env.STATE_DIR = stateDir;
@ -23,11 +27,11 @@ require('yargs/yargs')(process.argv.slice(2))
const checks = require(`../src/checks/${type}`); const checks = require(`../src/checks/${type}`);
const entry = { const entry = {
date: new Date().toISOString(), date: new Date().toISOString(),
checks: await Promise.all(checks.map((check) => new Promise(check))), checks: await Promise.all(checks.map((check) => new Promise(check))),
}; };
// read before writing to make sure no external changes are overwritten // read before writing to make sure no external changes are overwritten
db.read().get(type).push(entry).write(); db.read().get(type).push(entry).write();
}) }
.argv ).argv;