fix activation

pull/3285/head
filip mertens 2 years ago
parent 7e8d60a8d1
commit 92c2962592
  1. 13
      libs/remixd/src/services/foundryClient.ts
  2. 11
      libs/remixd/src/services/hardhatClient.ts
  3. 11
      libs/remixd/src/services/truffleClient.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)

@ -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', () => {

@ -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)
}

Loading…
Cancel
Save