From 2f1ec00e2931309207d541695c9284c6e724089a Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 26 Jan 2021 17:00:13 +0100 Subject: [PATCH] fix code style --- packages/health-check/src/checks/critical.js | 4 +-- packages/health-check/src/run.js | 36 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/health-check/src/checks/critical.js b/packages/health-check/src/checks/critical.js index 4fded35a..9f616037 100644 --- a/packages/health-check/src/checks/critical.js +++ b/packages/health-check/src/checks/critical.js @@ -1,6 +1,6 @@ const fs = require("fs"); const superagent = require("superagent"); -const tmp = require('tmp'); +const tmp = require("tmp"); const { StatusCodes } = require("http-status-codes"); const { calculateElapsedTime, getResponseContent } = require("../utils"); @@ -8,7 +8,7 @@ const { calculateElapsedTime, getResponseContent } = require("../utils"); async function uploadCheck(done) { const time = process.hrtime(); const file = tmp.fileSync(); - + fs.writeSync(file.fd, Buffer.from(new Date())); // write current date to temp file superagent diff --git a/packages/health-check/src/run.js b/packages/health-check/src/run.js index b6592727..fdabdea9 100644 --- a/packages/health-check/src/run.js +++ b/packages/health-check/src/run.js @@ -1,21 +1,25 @@ -require('yargs/yargs')(process.argv.slice(2)) - .command('$0 ', 'Skynet portal health checks', (yargs) => { - yargs.positional('type', { - describe: 'Type of checks to run', - type: 'string', - choices: ["critical", "verbose"] - }) - .option("portal-url", { +require("yargs/yargs")(process.argv.slice(2)).command( + "$0 ", + "Skynet portal health checks", + (yargs) => { + yargs + .positional("type", { + describe: "Type of checks to run", + type: "string", + choices: ["critical", "verbose"], + }) + .option("portal-url", { describe: "Skynet portal url", default: process.env.PORTAL_URL || "https://siasky.net", type: "string", - }) - .option("state-dir", { + }) + .option("state-dir", { describe: "State directory", default: process.env.STATE_DIR || "state", type: "string", - }) - }, async ({ type, portalUrl, stateDir }) => { + }); + }, + async ({ type, portalUrl, stateDir }) => { process.env.PORTAL_URL = portalUrl; process.env.STATE_DIR = stateDir; @@ -23,11 +27,11 @@ require('yargs/yargs')(process.argv.slice(2)) const checks = require(`../src/checks/${type}`); const entry = { - date: new Date().toISOString(), - checks: await Promise.all(checks.map((check) => new Promise(check))), + date: new Date().toISOString(), + checks: await Promise.all(checks.map((check) => new Promise(check))), }; // read before writing to make sure no external changes are overwritten db.read().get(type).push(entry).write(); - }) - .argv + } +).argv;