diff --git a/lib/linter-rust.coffee b/lib/linter-rust.coffee index 2254d4d..e951773 100644 --- a/lib/linter-rust.coffee +++ b/lib/linter-rust.coffee @@ -3,12 +3,14 @@ Linter = require "#{linterPath}/lib/linter" {exec} = require 'child_process' {log, warn} = require "#{linterPath}/lib/utils" +fs = require 'fs' path = require 'path' class LinterRust extends Linter - @enable: false + @enabled: false @syntax: 'source.rust' + @rustcPath: '' linterName: 'rust' errorStream: 'stderr' regex: '(.+):(?\\d+):(?\\d+):\\s*(\\d+):(\\d+)\\s+((?error|fatal error)|(?warning)|(?note)):\\s+(?.+)\n' @@ -16,8 +18,11 @@ class LinterRust extends Linter constructor: (@editor) -> super @editor atom.config.observe 'linter-rust.executablePath', => - @executablePath = atom.config.get 'linter-rust.executablePath' - exec "#{@executablePath} --version", @executionCheckHandler + rustcPath = atom.config.get 'linter-rust.executablePath' + if rustcPath != @rustcPath + @enabled = false + @rustcPath = rustcPath + exec "#{@rustcPath} --version", @executionCheckHandler executionCheckHandler: (error, stdout, stderr) => versionRegEx = /rustc ([\d\.]+)/ @@ -25,7 +30,7 @@ class LinterRust extends Linter result = if error? then '#' + error.code + ': ' else '' result += 'stdout: ' + stdout if stdout.length > 0 result += 'stderr: ' + stderr if stderr.length > 0 - console.error "Linter-Rust: \"#{@executablePath}\" was not executable: \ + console.error "Linter-Rust: \"#{@rustcPath}\" was not executable: \ \"#{result}\". Please, check executable path in the linter settings." else @enabled = true @@ -33,7 +38,7 @@ class LinterRust extends Linter do @initCmd initCmd: => - @cmd = "#{@executablePath} -Z no-trans --color never" + @cmd = "#{@rustcPath} -Z no-trans --color never" log 'Linter-Rust: initialization completed' lintFile: (filePath, callback) =>