From 7123823081db32becfc71095bba43f4b9218c258 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 May 2022 09:37:03 +0200 Subject: [PATCH] check if file exist --- apps/remix-ide/src/app/editor/editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 11962f268b..ebbb52f4cb 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -185,8 +185,10 @@ class Editor extends Plugin { if (path.startsWith('./') || path.startsWith('../')) path = resolve(fromPath, path) if (path.startsWith('/')) path = path.substring(1) if (!path.endsWith('.ts')) path = path + '.ts' - content = await this.call('fileManager', 'readFile', path) - this.emit('addModel', content, 'typescript', path, false) + if (await this.call('fileManager', 'exists', path)) { + content = await this.call('fileManager', 'readFile', path) + this.emit('addModel', content, 'typescript', path, false) + } } } })