Merge pull request #1550 from ethereum/addRemixCommands

Add remix command "setFile"
pull/1/head
yann300 6 years ago committed by GitHub
commit b95fc58ce9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/app/plugin/pluginAPI.js
  2. 16
      src/lib/cmdInterpreterAPI.js

@ -123,6 +123,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
provider.set(path, content, (error) => { provider.set(path, content, (error) => {
if (error) return cb(error) if (error) return cb(error)
fileManager.syncEditor(path) fileManager.syncEditor(path)
cb()
}) })
} else { } else {
cb(path + ' not available') cb(path + ' not available')

@ -28,7 +28,8 @@ class CmdInterpreterAPI {
offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api offsetToLineColumnConverter: self._components.registry.get('offsettolinecolumnconverter').api
} }
self.commandHelp = { 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.debug(hash)': 'Start debugging a transaction.',
'remix.loadgist(id)': 'Load a gist in the file explorer.', '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', '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,19 @@ class CmdInterpreterAPI {
cb('file not found') cb('file not found')
} }
} }
setFile (path, content, cb) {
cb = cb || function () {}
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) { execute (file, cb) {
const self = this const self = this

Loading…
Cancel
Save