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