diff --git a/libs/remixd/src/services/remixdClient.ts b/libs/remixd/src/services/remixdClient.ts index a3f3d9dd8f..4718cfbcf1 100644 --- a/libs/remixd/src/services/remixdClient.ts +++ b/libs/remixd/src/services/remixdClient.ts @@ -5,12 +5,14 @@ import * as utils from '../utils' import * as chokidar from 'chokidar' import * as fs from 'fs-extra' import * as isbinaryfile from 'isbinaryfile' +import * as pathModule from 'path' export class RemixdClient extends PluginClient { methods: Array websocket: WS currentSharedFolder: string watcher: chokidar.FSWatcher + trackDownStreamUpdate: Record = {} constructor (private readOnly = false) { super() @@ -105,6 +107,7 @@ export class RemixdClient extends PluginClient { this.createDir({ path: args.path.substr(0, args.path.lastIndexOf('/')) }) } try { + this.trackDownStreamUpdate[path] = args.content fs.writeFile(path, args.content, 'utf8', (error: Error) => { if (error) { console.log(error) @@ -263,8 +266,9 @@ export class RemixdClient extends PluginClient { }) */ this.watcher.on('change', async (f: string) => { - const currentContent = await this.call('editor', 'getText' as any, f) - const newContent = fs.readFileSync(f) + const path = pathModule.resolve(f) + const currentContent = this.trackDownStreamUpdate[path] + const newContent = fs.readFileSync(f, 'utf-8') if (currentContent !== newContent && this.isLoaded) { this.emit('changed', utils.relativePath(f, this.currentSharedFolder)) }