diff --git a/apps/remix-ide/src/app/files/file-explorer.js b/apps/remix-ide/src/app/files/file-explorer.js index e829d42dd9..69ab1f6700 100644 --- a/apps/remix-ide/src/app/files/file-explorer.js +++ b/apps/remix-ide/src/app/files/file-explorer.js @@ -16,7 +16,7 @@ const globalRegistry = require('../../global/registry') const queryParams = new QueryParams() let MENU_HANDLE -function fileExplorer (localRegistry, files, menuItems) { +function fileExplorer (localRegistry, files, menuItems, plugin) { var self = this this.events = new EventManager() // file provider backend @@ -292,6 +292,14 @@ function fileExplorer (localRegistry, files, menuItems) { () => {} ) } + if (key.endsWith('.js')) { + actions['Run Script'] = async () => { + provider.get(key, (error, content) => { + if (error) return console.log(error) + plugin.call('scriptRunner', 'execute', content) + }) + } + } } MENU_HANDLE = contextMenu(event, actions) }) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 8927981620..32d8a1e303 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -54,7 +54,7 @@ module.exports = class Filepanel extends ViewPlugin { } function createProvider (key, menuItems) { - return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems) + return new FileExplorer(self._components.registry, self._deps.fileProviders[key], menuItems, self) } var fileExplorer = createProvider('browser', ['createNewFile', 'publishToGist', canUpload ? 'uploadFile' : ''])