@@ -56,8 +56,7 @@ const COMMON_EDITORS_OSX = {
56
56
'/Applications/RubyMine.app/Contents/MacOS/rubymine' ,
57
57
'/Applications/WebStorm.app/Contents/MacOS/webstorm' :
58
58
'/Applications/WebStorm.app/Contents/MacOS/webstorm' ,
59
- '/Applications/MacVim.app/Contents/MacOS/MacVim' :
60
- 'mvim' ,
59
+ '/Applications/MacVim.app/Contents/MacOS/MacVim' : 'mvim' ,
61
60
} ;
62
61
63
62
const COMMON_EDITORS_LINUX = {
@@ -188,23 +187,19 @@ function guessEditor() {
188
187
}
189
188
}
190
189
} else if ( process . platform === 'win32' ) {
190
+ // Some processes need elevated rights to get its executable path.
191
+ // Just filter them out upfront. This also saves 10-20ms on the command.
191
192
const output = child_process
192
- . execSync ( 'powershell -Command "Get-Process | Select-Object Path"' , {
193
- stdio : [ 'pipe' , 'pipe' , 'ignore' ] ,
194
- } )
193
+ . execSync (
194
+ 'wmic process where "executablepath is not null" get executablepath'
195
+ )
195
196
. toString ( ) ;
196
197
const runningProcesses = output . split ( '\r\n' ) ;
197
198
for ( let i = 0 ; i < runningProcesses . length ; i ++ ) {
198
- // `Get-Process` sometimes returns empty lines
199
- if ( ! runningProcesses [ i ] ) {
200
- continue ;
201
- }
202
-
203
- const fullProcessPath = runningProcesses [ i ] . trim ( ) ;
204
- const shortProcessName = path . basename ( fullProcessPath ) ;
205
-
206
- if ( COMMON_EDITORS_WIN . indexOf ( shortProcessName ) !== - 1 ) {
207
- return [ fullProcessPath ] ;
199
+ const processPath = runningProcesses [ i ] . trim ( ) ;
200
+ const processName = path . basename ( processPath ) ;
201
+ if ( COMMON_EDITORS_WIN . indexOf ( processName ) !== - 1 ) {
202
+ return [ processPath ] ;
208
203
}
209
204
}
210
205
} else if ( process . platform === 'linux' ) {
0 commit comments