|
|
@ -1,5 +1,5 @@ |
|
|
|
import { PluginClient } from '@remixproject/plugin' |
|
|
|
import { PluginClient } from '@remixproject/plugin' |
|
|
|
import { SharedFolderArgs, TrackDownStreamUpdate, Filelist, ResolveDirectory, FileContent } from '../types' // eslint-disable-line
|
|
|
|
import { SharedFolderArgs, Filelist, ResolveDirectory, FileContent } from '../types' // eslint-disable-line
|
|
|
|
import * as WS from 'ws' // eslint-disable-line
|
|
|
|
import * as WS from 'ws' // eslint-disable-line
|
|
|
|
import * as utils from '../utils' |
|
|
|
import * as utils from '../utils' |
|
|
|
import * as chokidar from 'chokidar' |
|
|
|
import * as chokidar from 'chokidar' |
|
|
@ -8,7 +8,6 @@ import * as isbinaryfile from 'isbinaryfile' |
|
|
|
|
|
|
|
|
|
|
|
export class RemixdClient extends PluginClient { |
|
|
|
export class RemixdClient extends PluginClient { |
|
|
|
methods: Array<string> |
|
|
|
methods: Array<string> |
|
|
|
trackDownStreamUpdate: TrackDownStreamUpdate = {} |
|
|
|
|
|
|
|
websocket: WS |
|
|
|
websocket: WS |
|
|
|
currentSharedFolder: string |
|
|
|
currentSharedFolder: string |
|
|
|
watcher: chokidar.FSWatcher |
|
|
|
watcher: chokidar.FSWatcher |
|
|
@ -101,7 +100,6 @@ export class RemixdClient extends PluginClient { |
|
|
|
console.log('trying to write "undefined" ! stopping.') |
|
|
|
console.log('trying to write "undefined" ! stopping.') |
|
|
|
return reject(new Error('trying to write "undefined" ! stopping.')) |
|
|
|
return reject(new Error('trying to write "undefined" ! stopping.')) |
|
|
|
} |
|
|
|
} |
|
|
|
this.trackDownStreamUpdate[path] = path |
|
|
|
|
|
|
|
if (!exists && args.path.indexOf('/') !== -1) { |
|
|
|
if (!exists && args.path.indexOf('/') !== -1) { |
|
|
|
// the last element is the filename and we should remove it
|
|
|
|
// the last element is the filename and we should remove it
|
|
|
|
this.createDir({ path: args.path.substr(0, args.path.lastIndexOf('/')) }) |
|
|
|
this.createDir({ path: args.path.substr(0, args.path.lastIndexOf('/')) }) |
|
|
@ -265,13 +263,11 @@ export class RemixdClient extends PluginClient { |
|
|
|
}) |
|
|
|
}) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
this.watcher.on('change', async (f: string) => { |
|
|
|
this.watcher.on('change', async (f: string) => { |
|
|
|
if (this.trackDownStreamUpdate[f]) { |
|
|
|
const currentContent = await this.call('editor', 'getText' as any, f) |
|
|
|
delete this.trackDownStreamUpdate[f] |
|
|
|
const newContent = fs.readFileSync(f) |
|
|
|
return |
|
|
|
if (currentContent !== newContent && this.isLoaded) { |
|
|
|
} |
|
|
|
|
|
|
|
if (this.isLoaded) { |
|
|
|
|
|
|
|
this.emit('changed', utils.relativePath(f, this.currentSharedFolder)) |
|
|
|
this.emit('changed', utils.relativePath(f, this.currentSharedFolder)) |
|
|
|
} |
|
|
|
}
|
|
|
|
}) |
|
|
|
}) |
|
|
|
this.watcher.on('unlink', async (f: string) => { |
|
|
|
this.watcher.on('unlink', async (f: string) => { |
|
|
|
if (this.isLoaded) { |
|
|
|
if (this.isLoaded) { |
|
|
|