|
|
|
@ -16,20 +16,18 @@ export class IntelligentScriptExecutor extends Plugin { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onActivation () { |
|
|
|
|
this.on('solidity', 'compilationFinished', async (file, source, languageVersion, data, input, version) => { |
|
|
|
|
const currentFile = await this.call('fileManager', 'file')
|
|
|
|
|
if (data && data.sources[currentFile] && |
|
|
|
|
data.sources[currentFile].ast && data.sources[currentFile].ast.nodes && data.sources[currentFile].ast.nodes.length) { |
|
|
|
|
const nodes = data.sources[currentFile].ast.nodes |
|
|
|
|
for (let node of nodes) { |
|
|
|
|
if (node.documentation && node.documentation.text && node.documentation.text.startsWith('@custom:dev-run-script')) { |
|
|
|
|
const text = node.documentation.text.replace('@custom:dev-run-script', '').trim() |
|
|
|
|
await this.call('terminal', 'log', `running ${text} ...`) |
|
|
|
|
const content = await this.call('fileManager', 'readFile', text) |
|
|
|
|
await this.call('udapp', 'clearAllInstances') |
|
|
|
|
await this.call('scriptRunner', 'execute', content) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let listen = false |
|
|
|
|
setTimeout(() => { |
|
|
|
|
listen = true |
|
|
|
|
}, 500) |
|
|
|
|
this.on('compilerMetadata', 'artefactsUpdated', async (fileName, contract) => { |
|
|
|
|
if (!listen) return |
|
|
|
|
if (contract.object && contract.object.devdoc['custom:dev-run-script']) { |
|
|
|
|
const text = contract.object.devdoc['custom:dev-run-script'] |
|
|
|
|
await this.call('terminal', 'log', `running ${text} ...`) |
|
|
|
|
const content = await this.call('fileManager', 'readFile', text) |
|
|
|
|
await this.call('udapp', 'clearAllInstances') |
|
|
|
|
await this.call('scriptRunner', 'execute', content) |
|
|
|
|
}
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|