watch for file added

pull/5370/head
yann300 2 years ago
parent d3542913ff
commit 45667aa627
  1. 10
      libs/remixd/src/services/hardhatClient.ts

@ -59,13 +59,17 @@ export class HardhatClient extends PluginClient {
try { try {
const buildPath = utils.absolutePath('artifacts/build-info', this.currentSharedFolder) const buildPath = utils.absolutePath('artifacts/build-info', this.currentSharedFolder)
this.watcher = chokidar.watch(buildPath, { depth: 0, ignorePermissionErrors: true }) this.watcher = chokidar.watch(buildPath, { depth: 0, ignorePermissionErrors: true })
this.watcher.on('change', async (f: string) => {
const content = await fs.readFile(f, { encoding: 'utf-8' }) const processArtifact = async (path: string) => {
const content = await fs.readFile(path, { encoding: 'utf-8' })
const compilationResult = JSON.parse(content) const compilationResult = JSON.parse(content)
// @ts-ignore // @ts-ignore
this.call('terminal', 'log', 'received compilation result from hardhat') this.call('terminal', 'log', 'received compilation result from hardhat')
this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion) this.emit('compilationFinished', '', compilationResult.input, 'soljson', compilationResult.output, compilationResult.solcVersion)
}) }
this.watcher.on('change', (path: string) => processArtifact(path))
this.watcher.on('add', (path: string) => processArtifact(path))
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }

Loading…
Cancel
Save