diff --git a/libs/remixd/src/services/foundryClient.ts b/libs/remixd/src/services/foundryClient.ts index b7b49fbea0..e74988fb8c 100644 --- a/libs/remixd/src/services/foundryClient.ts +++ b/libs/remixd/src/services/foundryClient.ts @@ -20,6 +20,10 @@ export class FoundryClient extends PluginClient { constructor(private readOnly = false) { super() this.methods = ['compile', 'sync'] + this.onActivation = () => { + console.log('Foundry plugin activated') + this.startListening() + } } setWebSocket(websocket: WS): void { @@ -34,17 +38,18 @@ export class FoundryClient extends PluginClient { this.currentSharedFolder = currentSharedFolder this.buildPath = utils.absolutePath('out', this.currentSharedFolder) this.cachePath = utils.absolutePath('cache', this.currentSharedFolder) + } + + startListening() { if (fs.existsSync(this.buildPath) && fs.existsSync(this.cachePath)) { this.listenOnFoundryCompilation() } else { - console.log('Foundry out folder doesn\'t exist... waiting for the first compilation.') this.listenOnFoundryFolder() } } - - listenOnFoundryFolder() { + console.log('Foundry out folder doesn\'t exist... waiting for the compilation.') try { if(this.watcher) this.watcher.close() this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true }) @@ -119,7 +124,7 @@ export class FoundryClient extends PluginClient { clearTimeout(this.logTimeout) this.logTimeout = setTimeout(() => { // @ts-ignore - this.call('terminal', 'log', { type: 'log', value: 'receiving compilation result from Foundry' }) + this.call('terminal', 'log', { type: 'log', value: `receiving compilation result from Foundry` }) console.log('Syncing compilation result from Foundry') }, 1000) diff --git a/libs/remixd/src/services/hardhatClient.ts b/libs/remixd/src/services/hardhatClient.ts index e3d198156a..5c8095ed51 100644 --- a/libs/remixd/src/services/hardhatClient.ts +++ b/libs/remixd/src/services/hardhatClient.ts @@ -19,6 +19,10 @@ export class HardhatClient extends PluginClient { constructor(private readOnly = false) { super() this.methods = ['compile', 'sync'] + this.onActivation = () => { + console.log('Hardhat plugin activated') + this.startListening() + } } setWebSocket(websocket: WS): void { @@ -32,14 +36,15 @@ export class HardhatClient extends PluginClient { sharedFolder(currentSharedFolder: string): void { this.currentSharedFolder = currentSharedFolder this.buildPath = utils.absolutePath('artifacts/contracts', this.currentSharedFolder) + } + + startListening() { if (fs.existsSync(this.buildPath)) { this.listenOnHardhatCompilation() } else { - console.log('Hardhat artifacts folder doesn\'t exist... waiting for the first compilation.') console.log('If you are using Hardhat, run `npx hardhat compile` or run the compilation with `Enable Hardhat Compilation` checked from the Remix IDE.') this.listenOnHardHatFolder() } - } compile(configPath: string) { @@ -141,8 +146,8 @@ export class HardhatClient extends PluginClient { } listenOnHardHatFolder() { + console.log('Hardhat artifacts folder doesn\'t exist... waiting for the compilation.') try { - this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true }) // watch for new folders this.watcher.on('addDir', () => { diff --git a/libs/remixd/src/services/truffleClient.ts b/libs/remixd/src/services/truffleClient.ts index b11d4f8bf1..d4d388944e 100644 --- a/libs/remixd/src/services/truffleClient.ts +++ b/libs/remixd/src/services/truffleClient.ts @@ -19,6 +19,10 @@ export class TruffleClient extends PluginClient { constructor(private readOnly = false) { super() this.methods = ['compile', 'sync'] + this.onActivation = () => { + console.log('Truffle plugin activated') + this.startListening() + } } setWebSocket(websocket: WS): void { @@ -32,16 +36,20 @@ export class TruffleClient extends PluginClient { sharedFolder(currentSharedFolder: string): void { this.currentSharedFolder = currentSharedFolder this.buildPath = utils.absolutePath('build/contracts', this.currentSharedFolder) + + } + + startListening() { if (fs.existsSync(this.buildPath)) { this.listenOnTruffleCompilation() } else { - console.log('Truffle build folder doesn\'t exist... waiting for the first compilation.') this.listenOnTruffleFolder() } } listenOnTruffleFolder() { + console.log('Truffle build folder doesn\'t exist... waiting for the compilation.') try { this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true }) // watch for new folders @@ -120,6 +128,7 @@ export class TruffleClient extends PluginClient { } else { // @ts-ignore this.call('terminal', 'log', { value: 'receiving compilation result from Truffle', type: 'log' }) + console.log('Syncing compilation result from Truffle') } }, 1000) }