storing path in const

This commit is contained in:
Miodec 2022-03-10 15:26:01 +01:00
parent b54cf2b03f
commit bc9209e15e

View file

@ -6,9 +6,11 @@ import fs from "fs";
import db from "../init/db";
import MonkeyError from "../utils/error";
const PATH_TO_REPO = "../../../../monkeytype-new-quotes";
let git;
try {
git = simpleGit(path.join(__dirname, "../../../../monkeytype-new-quotes"));
git = simpleGit(path.join(__dirname, PATH_TO_REPO));
} catch (e) {
git = undefined;
}
@ -27,7 +29,7 @@ class NewQuotesDAO {
//check for duplicate first
const fileDir = path.join(
__dirname,
`../../../../monkeytype-new-quotes/static/quotes/${language}.json`
`${PATH_TO_REPO}/static/quotes/${language}.json`
);
let duplicateId = -1;
let similarityScore = -1;
@ -82,7 +84,7 @@ class NewQuotesDAO {
let message = "";
const fileDir = path.join(
__dirname,
`../../../monkeytype-new-quotes/static/quotes/${language}.json`
`${PATH_TO_REPO}/static/quotes/${language}.json`
);
await git.pull("upstream", "master");
if (fs.existsSync(fileDir)) {