Skip to content

Commit 585f819

Browse files
committed
Fix #22
1 parent 9040620 commit 585f819

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/git.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import * as child_process from "child_process";
2-
import * as path from "path";
2+
import { resolve } from "path";
33
import { Range } from "./Range";
44

55
const COMMAND = "git";
66

7-
const sanitizeFilePath = (filePath: string) =>
8-
JSON.stringify(path.resolve(filePath));
9-
107
const getDiffForFile = (filePath: string, staged = false): string => {
118
const args = [
129
"diff",
@@ -16,9 +13,9 @@ const getDiffForFile = (filePath: string, staged = false): string => {
1613
"--relative",
1714
staged && "--staged",
1815
"--unified=0",
19-
JSON.stringify(process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD"),
16+
process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD",
2017
"--",
21-
sanitizeFilePath(filePath),
18+
resolve(filePath),
2219
].reduce<string[]>(
2320
(acc, cur) => (typeof cur === "string" ? [...acc, cur] : acc),
2421
[]
@@ -36,15 +33,15 @@ const getDiffFileList = (): string[] => {
3633
"--name-only",
3734
"--relative",
3835
"--staged",
39-
JSON.stringify(process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD"),
36+
process.env.ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD",
4037
];
4138

4239
return child_process
4340
.execFileSync(COMMAND, args)
4441
.toString()
4542
.trim()
4643
.split("\n")
47-
.map((filePath) => path.resolve(filePath));
44+
.map((filePath) => resolve(filePath));
4845
};
4946

5047
const hasCleanIndex = (filePath: string): boolean => {
@@ -54,7 +51,7 @@ const hasCleanIndex = (filePath: string): boolean => {
5451
"--relative",
5552
"--unified=0",
5653
"--",
57-
sanitizeFilePath(filePath),
54+
resolve(filePath),
5855
];
5956

6057
let result = true;
@@ -79,7 +76,7 @@ const getUntrackedFileList = (staged = false): string[] => {
7976
.toString()
8077
.trim()
8178
.split("\n")
82-
.map((filePath) => path.resolve(filePath));
79+
.map((filePath) => resolve(filePath));
8380

8481
return untrackedFileListCache;
8582
};

0 commit comments

Comments
 (0)