File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -139,20 +139,27 @@ export class MicropythonFsHex implements FsInterface {
139139 * instance.
140140 *
141141 * @throws {Error } When there is a problem reading the files from the hex.
142- * @throws {Error } When a filename already exists in this instance.
142+ * @throws {Error } When a filename already exists in this instance (all other
143+ * files are still imported).
143144 *
144145 * @param intelHex - MicroPython hex string with files.
145146 * @param overwrite - Flag to overwrite existing files in this instance.
146147 * @returns A filename list of added files.
147148 */
148149 importFilesFromIntelHex ( intelHex : string , overwrite ?: boolean ) : string [ ] {
149150 const files = getIntelHexFiles ( intelHex ) ;
151+ const existingFiles : string [ ] = [ ] ;
150152 Object . keys ( files ) . forEach ( ( filename ) => {
151153 if ( ! overwrite && this . exists ( filename ) ) {
152- throw new Error ( `File "${ filename } " from hex already exists.` ) ;
154+ existingFiles . push ( filename ) ;
155+ } else {
156+ this . write ( filename , files [ filename ] ) ;
153157 }
154- this . write ( filename , files [ filename ] ) ;
155158 } ) ;
159+ // Only throw the error at the end so that all other files are imported
160+ if ( existingFiles . length ) {
161+ throw new Error ( `Files "${ existingFiles } " from hex already exists.` ) ;
162+ }
156163 return Object . keys ( files ) ;
157164 }
158165
You can’t perform that action at this time.
0 commit comments