Skip to content

Commit

Permalink
Replace all instances of yaml.safeLoad
Browse files Browse the repository at this point in the history
Function yaml.safeLoad is removed in js-yaml version 4. yaml.load is safe by default in version 4
  • Loading branch information
mikechernev committed Jan 5, 2021
1 parent 74c4523 commit bb49916
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/graphs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mkdirp, readFile, remove } from "fs-extra";
import { safeLoad } from "js-yaml";
import { load } from "js-yaml";
import { join } from "path";
import { exec } from "shelljs";
import { commit, push } from "./helpers/git";
Expand All @@ -11,7 +11,7 @@ export const generateGraphs = async () => {
if (!(await shouldContinue())) return;
await mkdirp("graphs");
await mkdirp("api");
const config = safeLoad(await readFile(join(".", ".upptimerc.yml"), "utf8")) as UpptimeConfig;
const config = load(await readFile(join(".", ".upptimerc.yml"), "utf8")) as UpptimeConfig;
exec("npx @upptime/graphs");
exec("npx imagemin-cli graphs/* --out-dir=graphs");
try {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/calculate-uptime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from "dayjs";
import { readFile } from "fs-extra";
import { safeLoad } from "js-yaml";
import { load } from "js-yaml";
import { join } from "path";
import { DownPecentages, Downtimes, SiteHistory } from "../interfaces";
import { getOctokit } from "./github";
Expand Down Expand Up @@ -90,7 +90,7 @@ const getDowntimeSecondsForSite = async (slug: string): Promise<Downtimes> => {
* @param slug - Slug of the site
*/
export const getUptimePercentForSite = async (slug: string): Promise<DownPecentages> => {
const site = safeLoad(
const site = load(
(await readFile(join(".", "history", `${slug}.yml`), "utf8"))
.split("\n")
.map((line) => (line.startsWith("- ") ? line.replace("- ", "") : line))
Expand Down
6 changes: 3 additions & 3 deletions src/update.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import slugify from "@sindresorhus/slugify";
import { mkdirp, readFile, writeFile } from "fs-extra";
import { safeLoad } from "js-yaml";
import { load } from "js-yaml";
import { join } from "path";
import { getConfig } from "./helpers/config";
import { commit, lastCommit, push } from "./helpers/git";
Expand All @@ -27,7 +27,7 @@ export const update = async (shouldCommit = false) => {
let currentStatus = "unknown";
let startTime = new Date();
try {
const siteHistory = safeLoad(
const siteHistory = load(
(await readFile(join(".", "history", `${slug}.yml`), "utf8"))
.split("\n")
.map((line) => (line.startsWith("- ") ? line.replace("- ", "") : line))
Expand Down Expand Up @@ -129,7 +129,7 @@ export const update = async (shouldCommit = false) => {
if (shouldCommit || currentStatus !== status) {
await writeFile(
join(".", "history", `${slug}.yml`),
`url: ${site.url}
`url: ${site.url}
status: ${status}
code: ${result.httpCode}
responseTime: ${responseTime}
Expand Down

0 comments on commit bb49916

Please sign in to comment.