Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make readonly immutable #1053

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions libs/remixd/src/bin/remixd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions libs/remixd/src/services/gitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand All @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions libs/remixd/src/services/remixdClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
Expand All @@ -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')
}

Expand Down