File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,16 @@ export async function resolveArduinoPath() {
1616 if ( directoryExistsSync ( pathString ) ) {
1717 return pathString ;
1818 }
19- pathString = childProcess . execSync ( "where arduino" , { encoding : "utf8" } ) ;
20- pathString = path . resolve ( pathString ) . trim ( ) ;
21- if ( fileExistsSync ( pathString ) ) {
22- pathString = path . dirname ( path . resolve ( pathString ) ) ;
19+ try {
20+ pathString = childProcess . execSync ( "where arduino" , { encoding : "utf8" } ) ;
21+ pathString = path . resolve ( pathString ) . trim ( ) ;
22+ if ( fileExistsSync ( pathString ) ) {
23+ pathString = path . dirname ( path . resolve ( pathString ) ) ;
24+ }
25+ } catch ( error ) {
26+ // when "where arduino"" execution fails, the childProcess.execSync will throw error, just ignore it
2327 }
28+
2429 return pathString ;
2530}
2631
@@ -32,7 +37,7 @@ export function findFile(fileName: string, cwd: string): string {
3237 let result ;
3338 try {
3439 let pathString ;
35- pathString = childProcess . execSync ( `dir ${ fileName } /S /B` , { encoding : "utf8" , cwd} ) . split ( "\n" ) ;
40+ pathString = childProcess . execSync ( `dir ${ fileName } /S /B` , { encoding : "utf8" , cwd } ) . split ( "\n" ) ;
3641 if ( pathString && pathString [ 0 ] && fileExistsSync ( pathString [ 0 ] . trim ( ) ) ) {
3742 result = path . normalize ( pathString [ 0 ] . trim ( ) ) ;
3843 }
You can’t perform that action at this time.
0 commit comments