From 71955d9b61ebfae56da795ffeadad3c9bfd738d8 Mon Sep 17 00:00:00 2001 From: Minh-Phuc Tran <25026967+phuctm97@users.noreply.github.com> Date: Sun, 3 Jul 2022 17:10:30 +0800 Subject: [PATCH] fix: run git init and git version in project directory --- src/utils/try-init-git.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/utils/try-init-git.ts b/src/utils/try-init-git.ts index a3af86d..e627bd4 100644 --- a/src/utils/try-init-git.ts +++ b/src/utils/try-init-git.ts @@ -1,6 +1,3 @@ -import path from "path"; -import fs from "fs/promises"; - import { exec } from "./async-exec"; async function isInGitRepository(projectDirectory: string): Promise { @@ -18,7 +15,9 @@ async function isInMercurialRepository( projectDirectory: string ): Promise { try { - await exec("hg --cwd . root", { cwd: projectDirectory }); + await exec("hg --cwd . root", { + cwd: projectDirectory, + }); return true; } catch { return false; @@ -27,14 +26,18 @@ async function isInMercurialRepository( export async function tryGitInit(projectDirectory: string): Promise { try { - await exec("git --version", { cwd: projectDirectory }); + await exec("git --version", { + cwd: projectDirectory, + }); if ( (await isInGitRepository(projectDirectory)) || (await isInMercurialRepository(projectDirectory)) ) { return false; } - await exec("git init"); + await exec("git init", { + cwd: projectDirectory, + }); return true; } catch { return false;