Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds support for relative setupPath #69

Merged
merged 2 commits into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/github/github-mocker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ActionMocker } from "@mg/github/action/action-mocker";
import { ActionMockerMethods } from "@mg/github/action/action-mocker.types";
import { EnvMocker } from "@mg/github/env/env-mocker";
import { EnvMethods } from "@mg/github/env/env-mocker.types";
import { Config } from "@mg/github/github-mocker.types";
import { Mocker } from "@mg/github/mocker";
import { RepositoryMocker } from "@mg/github/repository/repository-mocker";
import { readFileSync, mkdirSync, existsSync, rmSync } from "fs-extra";
import { EnvMethods } from "@mg/github/env/env-mocker.types";
import { ActionMockerMethods } from "@mg/github/action/action-mocker.types";
import { RepositoryStateMethods } from "@mg/github/repository/state/repository-state.types";
import Ajv from "ajv";
import { GithubConfigSchema } from "@mg/github/schema/github";
import Ajv from "ajv";
import { existsSync, mkdirSync, readFileSync, rmSync } from "fs-extra";
import path from "path";

export class MockGithub implements Mocker {
private actionMocker: ActionMocker;
Expand All @@ -21,7 +22,9 @@ export class MockGithub implements Mocker {

constructor(config: string | Config, setupPath: string = process.cwd()) {
this.config = this.validateConfig(config);
this.setupPath = setupPath;
this.setupPath = setupPath.startsWith("/")
? setupPath
: path.resolve(process.cwd(), setupPath);
this.actionMocker = new ActionMocker(this.config.action, this.setupPath);
this.envMocker = new EnvMocker(this.config.env);
this.repoMocker = new RepositoryMocker(this.config.repo, this.setupPath);
Expand Down Expand Up @@ -52,7 +55,7 @@ export class MockGithub implements Mocker {
]);

// rm the setup dir only if we had created it
if (this.setupDirCreated) {rmSync(this.setupPath, { recursive: true });}
if (this.setupDirCreated) { rmSync(this.setupPath, { recursive: true }); }

this.hasCalledSetup = false;
}
Expand Down