Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Fix uncaught error 'ENOENT'. See #3 and steelbrain/linter#330
Browse files Browse the repository at this point in the history
  • Loading branch information
gmist committed Mar 23, 2015
1 parent f0d6f48 commit c89fb61
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/linter-rust.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,42 @@ 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: '(.+):(?<line>\\d+):(?<col>\\d+):\\s*(\\d+):(\\d+)\\s+((?<error>error|fatal error)|(?<warning>warning)|(?<info>note)):\\s+(?<message>.+)\n'

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\.]+)/
if not versionRegEx.test(stdout)
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
log "Linter-Rust: found rust " + versionRegEx.exec(stdout)[1]
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) =>
Expand Down

0 comments on commit c89fb61

Please sign in to comment.