From 305674d71a8784731a337209c51d34200daabac3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 16 Feb 2017 21:15:39 -0500 Subject: [PATCH] Fixes pathing issue on Windows --- src/git/git.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index b8ba3dd..ccd570d 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -47,13 +47,17 @@ export default class Git { } static splitPath(fileName: string, repoPath?: string): [string, string] { - // if (!path.isAbsolute(fileName)) { - // Logger.error(`Git.splitPath(${fileName}) is not an absolute path!`); - // debugger; - // } - if (repoPath) return [fileName.replace(`${repoPath}/`, ''), repoPath]; + if (repoPath) { + return [ + fileName.replace(repoPath.endsWith('/') ? repoPath : `${repoPath}/`, ''), + repoPath + ]; + } - return [path.basename(fileName).replace(/\\/g, '/'), path.dirname(fileName).replace(/\\/g, '/')]; + return [ + path.basename(fileName).replace(/\\/g, '/'), + path.dirname(fileName).replace(/\\/g, '/') + ]; } static async repoPath(cwd: string, gitPath?: string) {