@@ -2,6 +2,8 @@ import * as child_process from "child_process";
2
2
import * as path from "path" ;
3
3
import { Range } from "./Range" ;
4
4
5
+ const RUNNING_INSIDE_VSCODE = process . env . VSCODE_CLI !== undefined ;
6
+
5
7
const sanitizeFilePath = ( filePath : string ) =>
6
8
JSON . stringify ( path . resolve ( filePath ) ) ;
7
9
@@ -17,10 +19,9 @@ const getCachedDiff = (filePath: string, staged: boolean) =>
17
19
18
20
const getDiffForFile = ( filePath : string , staged = false ) : string => {
19
21
let diff = getCachedDiff ( filePath , staged ) ;
20
- if ( diff === undefined ) {
22
+ if ( RUNNING_INSIDE_VSCODE || diff === undefined ) {
21
23
const command = [
22
24
"git" ,
23
- "--no-pager" ,
24
25
"diff" ,
25
26
"--diff-filter=ACM" ,
26
27
"--relative" ,
@@ -42,16 +43,15 @@ const getDiffForFile = (filePath: string, staged = false): string => {
42
43
} ;
43
44
44
45
let diffFileListCache : string [ ] | undefined ;
45
- const getDiffFileList = ( staged = false ) : string [ ] => {
46
- if ( diffFileListCache === undefined ) {
46
+ const getDiffFileList = ( ) : string [ ] => {
47
+ if ( RUNNING_INSIDE_VSCODE || diffFileListCache === undefined ) {
47
48
const command = [
48
49
"git" ,
49
- "--no-pager" ,
50
50
"diff" ,
51
51
"--diff-filter=ACM" ,
52
52
"--name-only" ,
53
53
"--relative" ,
54
- staged && "--staged" ,
54
+ "--staged" ,
55
55
JSON . stringify ( process . env . ESLINT_PLUGIN_DIFF_COMMIT ?? "HEAD" ) ,
56
56
]
57
57
. filter ( Boolean )
@@ -69,7 +69,8 @@ const getDiffFileList = (staged = false): string[] => {
69
69
70
70
let gitFileListCache : string [ ] | undefined ;
71
71
const getGitFileList = ( ) : string [ ] => {
72
- if ( gitFileListCache === undefined ) {
72
+ console . log ( "getGitFileList" ) ;
73
+ if ( RUNNING_INSIDE_VSCODE || gitFileListCache === undefined ) {
73
74
const command = [ "git" , "ls-files" ] . filter ( Boolean ) . join ( " " ) ;
74
75
75
76
gitFileListCache = child_process
@@ -86,7 +87,6 @@ const getGitFileList = (): string[] => {
86
87
const hasCleanIndex = ( filePath : string ) : boolean => {
87
88
const command = [
88
89
"git" ,
89
- "--no-pager" ,
90
90
"diff" ,
91
91
"--quiet" ,
92
92
"--relative" ,
@@ -109,7 +109,7 @@ let untrackedFileListCache: string[] | undefined;
109
109
const getUntrackedFileList = ( staged = false ) : string [ ] => {
110
110
if ( staged ) {
111
111
untrackedFileListCache = [ ] ;
112
- } else if ( untrackedFileListCache === undefined ) {
112
+ } else if ( RUNNING_INSIDE_VSCODE || untrackedFileListCache === undefined ) {
113
113
const command = [ "git" , "ls-files" , "--exclude-standard" , "--others" ]
114
114
. filter ( Boolean )
115
115
. join ( " " ) ;
0 commit comments