From d859692a1656400c41581f5b5b1b7c318a49f1b7 Mon Sep 17 00:00:00 2001 From: Mohacyr Rojas Date: Thu, 5 Oct 2023 10:12:40 -0600 Subject: [PATCH] fix: path to save .apimockrc file --- src/index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index 19992b6..198cc4d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,14 +1,11 @@ import { input, confirm } from "@inquirer/prompts"; import * as fs from "node:fs"; import OpenApiMocker from "open-api-mocker"; -import path from "path"; -import { fileURLToPath } from "url"; import cloneGitRepository from "./services/clone-git-repository.js"; import findOasFromDir from "./services/find-oas-from-dir.js"; -const __filename = fileURLToPath(import.meta.url); - -const __dirname = path.dirname(__filename); +const testRepoSSH = "git@gitlab.sngular.com:os3/manatee/sirenia.git"; +const testRepoHTTPS = "https://gitlab.sngular.com/os3/manatee/sirenia.git"; // TODO: replace by user input const main = async () => { const config = { @@ -23,7 +20,7 @@ const main = async () => { console.table(config); if (config.saveConfig) { - const filePath = `${__dirname}/.apimockrc`; + const filePath = `${process.cwd()}/.apimockrc`; fs.writeFile(filePath, JSON.stringify(config), (err) => { if (err) { console.error(err); @@ -33,11 +30,9 @@ const main = async () => { }); } - const testRepoSSH = "git@gitlab.sngular.com:os3/manatee/sirenia.git"; // TODO: replace by user input - const testRepoHTTPS = "https://gitlab.sngular.com/os3/manatee/sirenia.git"; // TODO: replace by user input await cloneGitRepository(config.repoUrl || testRepoSSH); - const schemas = await findOasFromDir('./tests'); + const schemas = await findOasFromDir("./tests"); const openApiMocker = new OpenApiMocker({ port: 5000,