Skip to content

Commit 22019cd

Browse files
author
ci-bot
committed
listen on build done
1 parent d4ac52a commit 22019cd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

apps/remixdesktop/src/plugins/foundryPlugin.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ class FoundryPluginClient extends ElectronBasePluginRemixdClient {
5555
const cache = JSON.parse(await fs.promises.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' }))
5656
this.emitContract(basename(currentFile), cache)
5757
})
58+
this.listenOnFoundryCompilation()
59+
}
60+
61+
listenOnFoundryCompilation() {
62+
try {
63+
if (this.watcher) this.watcher.close()
64+
this.watcher = chokidar.watch(this.cachePath, { depth: 0, ignorePermissionErrors: true, ignoreInitial: true })
65+
this.watcher.on('change', async () => {
66+
const currentFile = await this.call('fileManager', 'getCurrentFile')
67+
const cache = JSON.parse(await fs.promises.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' }))
68+
this.emitContract(basename(currentFile), cache)
69+
})
70+
this.watcher.on('add', async () => {
71+
const currentFile = await this.call('fileManager', 'getCurrentFile')
72+
const cache = JSON.parse(await fs.promises.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' }))
73+
this.emitContract(basename(currentFile), cache)
74+
})
75+
} catch (e) {
76+
console.log(e)
77+
}
5878
}
5979

6080
compile() {

0 commit comments

Comments
 (0)