Merge pull request #1053 from ethereum/immutable-readonly

Make readonly immutable
pull/5370/head
David Disu 4 years ago committed by GitHub
commit f3396feef6
  1. 10
      libs/remixd/src/bin/remixd.ts
  2. 6
      libs/remixd/src/services/gitClient.ts
  3. 6
      libs/remixd/src/services/remixdClient.ts

@ -9,8 +9,8 @@ import * as path from 'path'
import * as program from 'commander'
const services = {
git: () => new servicesList.GitClient(),
folder: () => new servicesList.Sharedfolder()
git: (readOnly: boolean) => new servicesList.GitClient(readOnly),
folder: (readOnly: boolean) => new servicesList.Sharedfolder(readOnly)
}
const ports = {
@ -20,7 +20,7 @@ const ports = {
const killCallBack: Array<Function> = []
function startService<S extends 'git' | 'folder'> (service: S, callback: (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => void) {
const socket = new WebSocket(ports[service], { remixIdeUrl: program.remixIde }, () => services[service]())
const socket = new WebSocket(ports[service], { remixIdeUrl: program.remixIde }, () => services[service](program.readOnly || false))
socket.start(callback)
killCallBack.push(socket.close.bind(socket))
}
@ -57,12 +57,12 @@ function startService<S extends 'git' | 'folder'> (service: S, callback: (ws: WS
startService('folder', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => {
sharedFolderClient.setWebSocket(ws)
sharedFolderClient.setupNotifications(program.sharedFolder)
sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false)
sharedFolderClient.sharedFolder(program.sharedFolder)
})
startService('git', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => {
sharedFolderClient.setWebSocket(ws)
sharedFolderClient.sharedFolder(program.sharedFolder, program.readOnly || false)
sharedFolderClient.sharedFolder(program.sharedFolder)
})
} catch (error) {
throw new Error(error)

@ -6,9 +6,8 @@ export class GitClient extends PluginClient {
methods: Array<string>
websocket: WS
currentSharedFolder: string
readOnly: boolean
constructor () {
constructor (private readOnly = false) {
super()
this.methods = ['execute']
}
@ -17,9 +16,8 @@ export class GitClient extends PluginClient {
this.websocket = websocket
}
sharedFolder (currentSharedFolder: string, readOnly: boolean): void {
sharedFolder (currentSharedFolder: string): void {
this.currentSharedFolder = currentSharedFolder
this.readOnly = readOnly
}
execute (cmd: string) {

@ -11,9 +11,8 @@ export class RemixdClient extends PluginClient {
trackDownStreamUpdate: TrackDownStreamUpdate = {}
websocket: WS
currentSharedFolder: string
readOnly: boolean
constructor () {
constructor (private readOnly = false) {
super()
this.methods = ['folderIsReadOnly', 'resolveDirectory', 'get', 'exists', 'isFile', 'set', 'rename', 'remove', 'isDirectory', 'list', 'createDir']
}
@ -22,9 +21,8 @@ export class RemixdClient extends PluginClient {
this.websocket = websocket
}
sharedFolder (currentSharedFolder: string, readOnly: boolean): void {
sharedFolder (currentSharedFolder: string): void {
this.currentSharedFolder = currentSharedFolder
this.readOnly = readOnly
if (this.isLoaded) this.emit('rootFolderChanged')
}

Loading…
Cancel
Save