Skip to content

Commit

Permalink
fix(clone-repo): remove waitUserInput function
Browse files Browse the repository at this point in the history
This function was temporary while there was no command tool.
  • Loading branch information
MHCYR committed Oct 9, 2023
1 parent d22b68a commit 65bbe76
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/services/clone-git-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
// - tests
// - doc

import { execSync } from 'child_process';
import * as fs from 'fs';
import path from 'path';
import * as readline from 'readline';
import process from 'process';
import { execSync } from "child_process";
import * as fs from "fs";
import path from "path";
import process from "process";

const TEMP_FOLDER_NAME = ".api-mock-runner"; // TODO: extract to configuration file?

async function cloneSchemaRepo(repositoryURL) {
resetTempDir();
cloneRepository(repositoryURL);
printDirectoryContent();
await waitUserInput(); // FIXME: Temp until command line interface is finished
}

function resetTempDir() {
Expand All @@ -37,26 +35,9 @@ function cloneRepository(repositoryURL) {
}

function printDirectoryContent() {
console.log("Directory content:"); // FIXME: console.log
fs.readdirSync(TEMP_FOLDER_NAME).forEach((file) => {
console.log(` - ${file}`);
});
}

async function waitUserInput() {
const readLineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

const message = "Waiting user input to finish...";
return new Promise((resolve) =>
readLineInterface.question(message, answer => {
readLineInterface.close();
removeTempDir();
resolve(answer);
})
);
}

export default cloneSchemaRepo;

0 comments on commit 65bbe76

Please sign in to comment.