From 6e7365a8c47c89eaab93c73e4a0b4ce4e69d0cb1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 7 Jul 2021 12:24:08 +0200 Subject: Added env variables for testing & fixed other test stuff --- test/setup.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/setup.ts (limited to 'test/setup.ts') diff --git a/test/setup.ts b/test/setup.ts new file mode 100644 index 0000000..d0b1410 --- /dev/null +++ b/test/setup.ts @@ -0,0 +1,34 @@ +import { access, mkdir, remove, copy } from "fs-extra"; +import { promisify } from "util"; +import { exec } from "child_process"; +import { config } from "dotenv"; + +const promiseExec = promisify(exec); +config({ path: "test/test.env" }); + +export default async function init() { + const can_access = await access(process.env.BASE_DIR) + .then(() => true) + .catch(() => false); + + console.log(can_access); + + if(can_access) { + await remove(process.env.BASE_DIR); + } + + await mkdir(process.env.BASE_DIR); + await mkdir(`${process.env.BASE_DIR}/${process.env.AVAIL_REPO}`); + + await copy(".git", `${process.env.BASE_DIR}/${process.env.AVAIL_REPO}`); + + process.chdir(`${process.env.BASE_DIR}/${process.env.AVAIL_REPO}`); + + const { stdout, stderr } = await promiseExec("git config core.bare true"); + + if(stderr) { + throw(stderr); + } + + process.chdir("../.."); +} \ No newline at end of file -- cgit v1.2.3-18-g5258