Merge pull request #53 from tjanson/read-only-mode

add --read-only flag which prevents all writes
pull/454/head
yann300 6 years ago committed by GitHub
commit 8b0eeb7512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      bin/remixd
  2. 6
      src/services/sharedFolder.js

@ -10,6 +10,7 @@ program
.usage('-s <shared folder>')
.description('Provide a two ways connection between the local computer and Remix IDE')
.option('-s, --shared-folder <path>', 'Folder to share with Remix IDE')
.option('--read-only', 'Treat shared folder as read-only (experimental)')
.option('-m, --mist', 'start mist')
.option('-g, --geth', 'start geth')
.option('-p, --dev-path <dev-path>', 'Folder used by mist/geth to start the development instance')
@ -48,7 +49,7 @@ if (program.sharedFolder) {
var sharedFolderrouter = new Router(65520, servicesList['sharedfolder'], (webSocket) => {
servicesList['sharedfolder'].setWebSocket(webSocket)
servicesList['sharedfolder'].setupNotifications(program.sharedFolder)
servicesList['sharedfolder'].sharedFolder(program.sharedFolder)
servicesList['sharedfolder'].sharedFolder(program.sharedFolder, program.readOnly)
})
killCallBack.push(sharedFolderrouter.start())
}

@ -12,8 +12,9 @@ module.exports = {
this.websocket = websocket
},
sharedFolder: function (sharedFolder) {
sharedFolder: function (sharedFolder, readOnly) {
this.sharedFolder = sharedFolder
this.readOnly = readOnly
},
list: function (args, cb) {
@ -62,6 +63,7 @@ module.exports = {
},
set: function (args, cb) {
if (this.readOnly) return cb('Cannot write file: read-only mode selected')
var path = utils.absolutePath(args.path, this.sharedFolder)
if (fs.existsSync(path) && !isRealPath(path, cb)) return
if (args.content === 'undefined') { // no !!!!!
@ -76,6 +78,7 @@ module.exports = {
},
rename: function (args, cb) {
if (this.readOnly) return cb('Cannot rename file: read-only mode selected')
var oldpath = utils.absolutePath(args.oldPath, this.sharedFolder)
if (!fs.existsSync(oldpath)) {
return cb('File not found ' + oldpath)
@ -89,6 +92,7 @@ module.exports = {
},
remove: function (args, cb) {
if (this.readOnly) return cb('Cannot remove file: read-only mode selected')
var path = utils.absolutePath(args.path, this.sharedFolder)
if (!fs.existsSync(path)) {
return cb('File not found ' + path)

Loading…
Cancel
Save