Skip to content

Commit

Permalink
do not compile not sol/yul files
Browse files Browse the repository at this point in the history
  • Loading branch information
LianaHus committed Mar 19, 2020
1 parent 3cecdb0 commit bde41fa
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/app/tabs/compileTab/compilerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ class CompilerContainer {
}
if (!this._view.compilationButton) return
const button = this.compilationButton(name.split('/').pop())
this._disableCompileBtn(!name)
this._disableCompileBtn(!name || (name && !this.isSolFileSelected(name)))
yo.update(this._view.compilationButton, button)
}

isSolFileSelected (currentFile = '') {
if (!currentFile) currentFile = this.config.get('currentFile')
if (!currentFile) return false
return currentFile.substr(currentFile.length - 3, currentFile.length) === 'sol' ||
currentFile.substr(currentFile.length - 3, currentFile.length) === 'yul'
}

deactivate () {
// deactivate editor listeners
this.editor.event.unregister('contentChanged')
Expand Down Expand Up @@ -113,7 +120,7 @@ class CompilerContainer {
*/
compilationButton (name = '') {
const displayed = name || '<no file selected>'
const disabled = name ? '' : 'disabled'
const disabled = name && this.isSolFileSelected() ? '' : 'disabled'
const compileBtn = yo`
<button id="compileBtn" data-id="compilerContainerCompileBtn" class="btn btn-primary btn-block ${disabled}" title="Compile" onclick="${this.compile.bind(this)}">
<span>${this._view.compileIcon} Compile ${displayed}</span>
Expand All @@ -131,7 +138,7 @@ class CompilerContainer {
if (!btn) return
if (shouldDisable) {
btn.classList.add('disabled')
} else if (this.config.get('currentFile')) {
} else if (this.isSolFileSelected()) {
btn.classList.remove('disabled')
}
}
Expand Down Expand Up @@ -316,10 +323,11 @@ class CompilerContainer {
}

compile (event) {
if (this.config.get('currentFile')) {
this._setCompilerVersionFromPragma(this.config.get('currentFile'))
this.compileTabLogic.runCompiler()
}
const currentFile = this.config.get('currentFile')
if (!this.isSolFileSelected()) return

this._setCompilerVersionFromPragma(currentFile)
this.compileTabLogic.runCompiler()
}

compileIfAutoCompileOn () {
Expand Down

0 comments on commit bde41fa

Please sign in to comment.