compiler configuration from remix IDE

pull/1202/head
aniket-engg 4 years ago committed by Aniket
parent 25edaefe26
commit 29b4eb7ef7
  1. 7
      apps/remix-ide/src/app/files/fileManager.js
  2. 13
      apps/remix-ide/src/app/tabs/compileTab/compileTab.js
  3. 3
      libs/remixd/src/services/hardhatClient.ts

@ -57,9 +57,10 @@ class FileManager extends Plugin {
this.mode = mode this.mode = mode
} }
async compileWithHardhat (cmd) { async compileWithHardhat (fileContent) {
console.log('Inside compileWithHardhat, calling hardhat compile using appManager') const configFilePath = 'remixCompiler.config.js'
return await this.appManager.call('hardhat', 'compile', cmd) this.setFileContent(configFilePath, fileContent)
return await this.appManager.call('hardhat', 'compile', configFilePath)
} }
limitPluginScope (path) { limitPluginScope (path) {

@ -83,7 +83,18 @@ class CompileTab {
console.log('mode is - ', this.fileManager.mode) console.log('mode is - ', this.fileManager.mode)
if (this.fileManager.mode === 'localhost') { if (this.fileManager.mode === 'localhost') {
console.log('calling compilehardhat') console.log('calling compilehardhat')
this.fileManager.compileWithHardhat('npx hardhat compile').then(console.log) const { currentVersion, optimize, runs } = this.compiler.state
const fileContent = `module.exports = {
solidity: '${currentVersion.substring(0, currentVersion.indexOf('+commit'))}',
settings: {
optimizer: {
enabled: ${optimize},
runs: ${runs}
}
}
}
`
this.fileManager.compileWithHardhat(fileContent).then(console.log)
} }
this.fileManager.saveCurrentFile() this.fileManager.saveCurrentFile()
this.miscApi.clearAnnotations() this.miscApi.clearAnnotations()

@ -21,7 +21,8 @@ export class HardhatClient extends PluginClient {
this.currentSharedFolder = currentSharedFolder this.currentSharedFolder = currentSharedFolder
} }
compile (cmd: string) { compile (configPath: string) {
const cmd = `npx hardhat compile --config ${configPath}`
const options = { cwd: this.currentSharedFolder, shell: true } const options = { cwd: this.currentSharedFolder, shell: true }
const child = spawn(cmd, options) const child = spawn(cmd, options)
let result = '' let result = ''

Loading…
Cancel
Save