From 3d07b4b6210c1a9bb2e0d2ace15efa1d7e929266 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 dade5f8015..076740cc73 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -165,8 +165,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) + } } } })