|
|
@ -32,7 +32,28 @@ export class FoundryClient extends PluginClient { |
|
|
|
this.currentSharedFolder = currentSharedFolder |
|
|
|
this.currentSharedFolder = currentSharedFolder |
|
|
|
this.buildPath = utils.absolutePath('out', this.currentSharedFolder) |
|
|
|
this.buildPath = utils.absolutePath('out', this.currentSharedFolder) |
|
|
|
this.cachePath = utils.absolutePath('cache', this.currentSharedFolder) |
|
|
|
this.cachePath = utils.absolutePath('cache', this.currentSharedFolder) |
|
|
|
|
|
|
|
if (fs.existsSync(this.buildPath) && fs.existsSync(this.cachePath)) { |
|
|
|
this.listenOnFoundryCompilation() |
|
|
|
this.listenOnFoundryCompilation() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.log('Foundry out folder doesn\'t exist... waiting for the first compilation.') |
|
|
|
|
|
|
|
this.listenOFoundryFolder() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listenOFoundryFolder() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
this.watcher = chokidar.watch(this.currentSharedFolder, { depth: 1, ignorePermissionErrors: true, ignoreInitial: true }) |
|
|
|
|
|
|
|
// watch for new folders
|
|
|
|
|
|
|
|
this.watcher.on('addDir', (path) => { |
|
|
|
|
|
|
|
if (fs.existsSync(this.buildPath) && fs.existsSync(this.cachePath)) { |
|
|
|
|
|
|
|
this.buildPath = path |
|
|
|
|
|
|
|
this.listenOnFoundryCompilation() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
compile(configPath: string) { |
|
|
|
compile(configPath: string) { |
|
|
@ -64,6 +85,8 @@ export class FoundryClient extends PluginClient { |
|
|
|
|
|
|
|
|
|
|
|
private async processArtifact() { |
|
|
|
private async processArtifact() { |
|
|
|
const folderFiles = await fs.readdir(this.buildPath) // "out" folder
|
|
|
|
const folderFiles = await fs.readdir(this.buildPath) // "out" folder
|
|
|
|
|
|
|
|
if (!fs.existsSync(join(this.cachePath, 'solidity-files-cache.json'))) return |
|
|
|
|
|
|
|
try { |
|
|
|
const cache = JSON.parse(await fs.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' })) |
|
|
|
const cache = JSON.parse(await fs.readFile(join(this.cachePath, 'solidity-files-cache.json'), { encoding: 'utf-8' })) |
|
|
|
|
|
|
|
|
|
|
|
// name of folders are file names
|
|
|
|
// name of folders are file names
|
|
|
@ -86,6 +109,9 @@ export class FoundryClient extends PluginClient { |
|
|
|
this.call('terminal', 'log', { type: 'log', value: 'receiving compilation result from Foundry' }) |
|
|
|
this.call('terminal', 'log', { type: 'log', value: 'receiving compilation result from Foundry' }) |
|
|
|
this.warnlog = true |
|
|
|
this.warnlog = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
listenOnFoundryCompilation() { |
|
|
|
listenOnFoundryCompilation() { |
|
|
|