1
- import { execSync } from 'node:child_process' ;
1
+ import { execFileSync } from 'node:child_process' ;
2
2
import { join , delimiter } from 'node:path' ;
3
3
import { constants , existsSync , accessSync } from 'node:fs' ;
4
4
@@ -125,13 +125,13 @@ export function findNvim(opt: FindNvimOptions = {}): Readonly<FindNvimResult> {
125
125
const matches = new Array < NvimVersion > ( ) ;
126
126
const invalid = new Array < NvimVersion > ( ) ;
127
127
for ( let i = 0 ; i !== pathLength ; i = i + 1 ) {
128
- const possibleNvimPath = join ( paths [ i ] , windows ? 'nvim.exe' : 'nvim' ) ;
129
- if ( existsSync ( possibleNvimPath ) ) {
128
+ const nvimPath = join ( paths [ i ] , windows ? 'nvim.exe' : 'nvim' ) ;
129
+ if ( existsSync ( nvimPath ) ) {
130
130
try {
131
- accessSync ( possibleNvimPath , constants . X_OK ) ;
132
- const nvimVersionFull = execSync (
133
- ` ${ possibleNvimPath } --version`
134
- ) . toString ( ) ;
131
+ accessSync ( nvimPath , constants . X_OK ) ;
132
+ const nvimVersionFull = execFileSync ( nvimPath , [
133
+ ' --version' ,
134
+ ] ) . toString ( ) ;
135
135
const nvimVersionMatch = nvimVersionRegex . exec ( nvimVersionFull ) ;
136
136
const buildTypeMatch = buildTypeRegex . exec ( nvimVersionFull ) ;
137
137
const luaJitVersionMatch = luaJitVersionRegex . exec ( nvimVersionFull ) ;
@@ -142,22 +142,22 @@ export function findNvim(opt: FindNvimOptions = {}): Readonly<FindNvimResult> {
142
142
) {
143
143
invalid . push ( {
144
144
nvimVersion : nvimVersionMatch [ 1 ] ,
145
- path : possibleNvimPath ,
145
+ path : nvimPath ,
146
146
buildType : buildTypeMatch [ 1 ] ,
147
147
luaJitVersion : luaJitVersionMatch [ 1 ] ,
148
148
} ) ;
149
149
} else {
150
150
matches . push ( {
151
151
nvimVersion : nvimVersionMatch [ 1 ] ,
152
- path : possibleNvimPath ,
152
+ path : nvimPath ,
153
153
buildType : buildTypeMatch [ 1 ] ,
154
154
luaJitVersion : luaJitVersionMatch [ 1 ] ,
155
155
} ) ;
156
156
}
157
157
}
158
158
} catch ( e ) {
159
159
invalid . push ( {
160
- path : possibleNvimPath ,
160
+ path : nvimPath ,
161
161
error : e ,
162
162
} ) ;
163
163
}
0 commit comments