You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Tries to detect whether the error was caused by an invalid main sketch file name.
656
+
* IDE2 should handle gracefully when there is an invalid sketch name. See the [spec](https://arduino.github.io/arduino-cli/latest/sketch-specification/#sketch-root-folder) for details.
657
+
* The CLI does not have error codes (https://github.com/arduino/arduino-cli/issues/1762), so IDE2 parses the error message and tries to guess it.
658
+
* This method does not check whether `requestSketchPath` exists. It's the responsibility of the caller who wishes to handle this error.
659
+
*/
660
+
functionisInvalidSketchNameError(
661
+
err: unknown,
662
+
requestSketchPath: string
663
+
): boolean{
664
+
// When trying to open `/Users/a.kitta/Desktop/untitled folder/sketch.ino`.
665
+
// CLI will throw `Can't open sketch: main file missing from sketch: /Users/a.kitta/Desktop/untitled folder/untitled folder.ino`
666
+
if(isNotFoundError(err)){
667
+
constino=requestSketchPath.endsWith('.ino');
668
+
constpde=requestSketchPath.endsWith('.pde');
669
+
if(ino||pde){
670
+
constdir=path.dirname(requestSketchPath);
671
+
constsketchName=path.basename(dir);
672
+
constregex=newRegExp(
673
+
`Can't open sketch: main file missing from sketch: ${path.join(
674
+
dir,
675
+
`${sketchName}.${ino ? 'ino' : 'pde'}`
676
+
)}`
677
+
);
678
+
returnregex.test(err.details);
679
+
}
680
+
}
681
+
returnfalse;
682
+
}
683
+
650
684
/*
651
685
* When a new sketch is created, add a suffix to distinguish it
0 commit comments