diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index e0ba1b5301..671c9de8c0 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.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 startService (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 (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) diff --git a/libs/remixd/src/services/gitClient.ts b/libs/remixd/src/services/gitClient.ts index f4ba43bd1e..d4658df554 100644 --- a/libs/remixd/src/services/gitClient.ts +++ b/libs/remixd/src/services/gitClient.ts @@ -6,9 +6,8 @@ export class GitClient extends PluginClient { methods: Array 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) { diff --git a/libs/remixd/src/services/remixdClient.ts b/libs/remixd/src/services/remixdClient.ts index 23bfd3ff96..121b7e677e 100644 --- a/libs/remixd/src/services/remixdClient.ts +++ b/libs/remixd/src/services/remixdClient.ts @@ -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') }