Skip to content

Commit

Permalink
Merge pull request #1550 from ethereum/addRemixCommands
Browse files Browse the repository at this point in the history
Add remix command "setFile"
  • Loading branch information
yann300 authored Oct 18, 2018
2 parents b8514e7 + 5c16a38 commit b95fc58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/plugin/pluginAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ module.exports = (pluginManager, fileProviders, fileManager, compiler, udapp) =>
provider.set(path, content, (error) => {
if (error) return cb(error)
fileManager.syncEditor(path)
cb()
})
} else {
cb(path + ' not available')
Expand Down
16 changes: 15 additions & 1 deletion src/lib/cmdInterpreterAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -172,6 +173,19 @@ class CmdInterpreterAPI {
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) {
const self = this

Expand Down

0 comments on commit b95fc58

Please sign in to comment.