diff options
author | HampusM <hampus@hampusmat.com> | 2021-07-07 12:24:08 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2021-07-07 12:24:08 +0200 |
commit | 6e7365a8c47c89eaab93c73e4a0b4ce4e69d0cb1 (patch) | |
tree | fef884af0240dad25d96008ccb0590f47d4d134f /test/setup.ts | |
parent | 1ba1c1ffd03adbee82869dae9fdc75767719b287 (diff) |
Added env variables for testing & fixed other test stuff
Diffstat (limited to 'test/setup.ts')
-rw-r--r-- | test/setup.ts | 34 |
1 files changed, 34 insertions, 0 deletions
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 |