From 9f470e7696bfa67dfd1d321b3a270c7271aad885 Mon Sep 17 00:00:00 2001 From: Patrick Eriksson Date: Thu, 8 Apr 2021 14:35:27 +0200 Subject: [PATCH] Fix errors omitted when in subdirectory --- src/git.test.ts | 2 +- src/git.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/git.test.ts b/src/git.test.ts index 20cbf4c..ca41955 100644 --- a/src/git.test.ts +++ b/src/git.test.ts @@ -54,7 +54,7 @@ describe("getDiffForFile", () => { const diffFromFile = getDiffForFile("./mockfile.js", true); const expectedArguments = - 'git diff --diff-filter=ACM --staged --unified=0 "1234567"'; + 'git diff --diff-filter=ACM --relative --staged --unified=0 "1234567"'; expect( mockedChildProcess.execSync.mock.calls[ mockedChildProcess.execSync.mock.calls.length - 1 diff --git a/src/git.ts b/src/git.ts index 62e65e1..72e3fb4 100644 --- a/src/git.ts +++ b/src/git.ts @@ -22,6 +22,7 @@ const getDiffForFile = (filePath: string, staged = false): string => { "git", "diff", "--diff-filter=ACM", + "--relative", staged && "--staged", "--unified=0", JSON.stringify(process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD"), @@ -47,6 +48,7 @@ const getDiffFileList = (staged = false): string[] => { "diff", "--diff-filter=ACM", "--name-only", + "--relative", staged && "--staged", JSON.stringify(process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD"), ]