@@ -21,7 +21,9 @@ export async function detectDefaultBinaryAtStart() {
2121 // https://zenn.dev/hd_nvim/articles/e49ef2c812ae8d#comment-0b861171ac40cb
2222 // https://github.com/ast-grep/ast-grep-vscode/issues/235
2323 // https://github.com/nodejs/node/issues/29532#issue-492569087
24- for ( const cmd of [ 'ast-grep' , 'ast-grep.exe' , 'ast-grep.cmd' ] ) {
24+ // `ast-grep.exe` should check first,
25+ // otherwise, it will be resolved to `ast-grep` in shell mode
26+ for ( const cmd of [ 'ast-grep.exe' , 'ast-grep.cmd' , 'ast-grep' ] ) {
2527 if ( await testBinaryExist ( cmd ) ) {
2628 defaultBinary = cmd
2729 return
@@ -45,13 +47,13 @@ export function resolveBinary() {
4547// see https://github.com/ast-grep/ast-grep-vscode/pull/448 for more information
4648// TL;DR: windows needs shell: true for non-exe command and quotation for command with space
4749export function normalizeCommandForWindows ( command : string ) {
50+ const isExe = command . toLowerCase ( ) . endsWith ( '.exe' )
4851 // windows user may input space in command
4952 const normalizedCommand =
50- / \s / . test ( command ) && ! command . endsWith ( '.exe' ) ? `"${ command } "` : command
53+ / \s / . test ( command ) && ! isExe ? `"${ command } "` : command
5154 return {
5255 normalizedCommand,
53- shell :
54- process . platform === 'win32' && ! command . toLowerCase ( ) . endsWith ( '.exe' ) ,
56+ shell : process . platform === 'win32' && ! isExe ,
5557 }
5658}
5759
0 commit comments