From ccbb64408ee1e97f474950c082039d9f925c6f3b Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 14 Oct 2018 13:55:49 +0200 Subject: [PATCH] add setFile --- src/lib/cmdInterpreterAPI.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/cmdInterpreterAPI.js b/src/lib/cmdInterpreterAPI.js index 5f6d8bbe8f..db6edd77b8 100644 --- a/src/lib/cmdInterpreterAPI.js +++ b/src/lib/cmdInterpreterAPI.js @@ -28,7 +28,8 @@ class CmdInterpreterAPI { offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api } self.commandHelp = { - 'remix.getFile(path)': 'Returns te content of the file located at the given path', + 'remix.getFile(path)': 'Returns the content of the file located at the given path', + 'remix.setFile(path, content)': 'set the content of the file located at the given path', 'remix.debug(hash)': 'Start debugging a transaction.', 'remix.loadgist(id)': 'Load a gist in the file explorer.', 'remix.loadurl(url)': 'Load the given url in the file explorer. The url can be of type github, swarm, ipfs or raw http', @@ -172,6 +173,18 @@ class CmdInterpreterAPI { cb('file not found') } } + setFile (path, content, cb) { + var provider = this._deps.fileManager.fileProviderOf(path) + if (provider) { + provider.set(path, content, (error) => { + if (error) return cb(error) + this._deps.fileManager.syncEditor(path) + cb() + }) + } else { + cb('file not found') + } + } execute (file, cb) { const self = this