From 6612fc8c59e04a568c80b5068426534d57294f06 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Mon, 17 Jun 2024 12:27:17 +0100 Subject: [PATCH] chore: run fixture commands in /tmp --- test/gitlog.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/gitlog.test.ts b/test/gitlog.test.ts index 371ef47..ba40da9 100644 --- a/test/gitlog.test.ts +++ b/test/gitlog.test.ts @@ -1,21 +1,22 @@ import fs from "fs"; +import os from "os"; import { execSync } from "child_process"; import gitlog from "../src"; -const testRepoLocation = `${__dirname}/test-repo-clone`; +const testRepoLocation = `${os.tmpdir()}/test-repo-clone`; -function execInTestDir(command: string) { - execSync(command, { cwd: __dirname, stdio: "ignore" }); +function execInTmpDir(command: string) { + execSync(command, { cwd: os.tmpdir(), stdio: "ignore" }); } describe("gitlog", () => { beforeEach(() => { - execInTestDir(`${__dirname}/delete-repo.sh`); - execInTestDir(`${__dirname}/create-repo.sh`); + execInTmpDir(`${__dirname}/delete-repo.sh`); + execInTmpDir(`${__dirname}/create-repo.sh`); }); afterAll(() => { - execInTestDir(`${__dirname}/delete-repo.sh`); + execInTmpDir(`${__dirname}/delete-repo.sh`); }); it("throws an error when repo is not provided", async () => {