Skip to content

Commit 652ad9f

Browse files
author
ci-bot
committed
add listening to hardhat change
1 parent 22019cd commit 652ad9f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/remixdesktop/src/plugins/hardhatPlugin.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,29 @@ class HardhatPluginClient extends ElectronBasePluginRemixdClient {
4848

4949
startListening() {
5050
this.buildPath = utils.absolutePath('artifacts/contracts', this.currentSharedFolder)
51+
this.cachePath = utils.absolutePath('cache', this.currentSharedFolder)
5152
this.on('fileManager', 'currentFileChanged', async (currentFile: string) => {
5253
this.emitContract(basename(currentFile))
5354
})
55+
this.listenOnHardhatCompilation()
5456
}
57+
58+
listenOnHardhatCompilation() {
59+
try {
60+
if (this.watcher) this.watcher.close()
61+
this.watcher = chokidar.watch(this.cachePath, { depth: 0, ignorePermissionErrors: true, ignoreInitial: true })
62+
this.watcher.on('change', async () => {
63+
const currentFile = await this.call('fileManager', 'getCurrentFile')
64+
this.emitContract(basename(currentFile))
65+
})
66+
this.watcher.on('add', async () => {
67+
const currentFile = await this.call('fileManager', 'getCurrentFile')
68+
this.emitContract(basename(currentFile))
69+
})
70+
} catch (e) {
71+
console.log('listenOnHardhatCompilation', e)
72+
}
73+
}
5574

5675
compile() {
5776
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)