@@ -2,7 +2,7 @@ linterPath = atom.packages.getLoadedPackage("linter").path
2
2
Linter = require " #{ linterPath} /lib/linter"
3
3
4
4
{exec } = require ' child_process'
5
- {log , warn } = require " #{ linterPath} /lib/utils"
5
+ {log , warn , findFile } = require " #{ linterPath} /lib/utils"
6
6
fs = require ' fs'
7
7
path = require ' path'
8
8
tmp = require (' tmp' )
@@ -15,7 +15,7 @@ class LinterRust extends Linter
15
15
linterName : ' rust'
16
16
errorStream : ' stderr'
17
17
regex : ' (?<file>.+):(?<line>\\ d+):(?<col>\\ d+):\\ s*(\\ d+):(\\ d+)\\ s+((?<error>error|fatal error)|(?<warning>warning)|(?<info>note)):\\ s+(?<message>.+)\n '
18
- cargoFilename : ' '
18
+ cargoManifestFilename : ' '
19
19
dependencyDir : " target/debug/deps"
20
20
tmpFile : null
21
21
lintOnChange : false
@@ -29,8 +29,8 @@ class LinterRust extends Linter
29
29
@enabled = false
30
30
@rustcPath = rustcPath
31
31
exec " \" #{ @rustcPath } \" --version" , @executionCheckHandler
32
- atom .config .observe ' linter-rust.cargoFilename ' , =>
33
- @cargoFilename = atom .config .get ' linter-rust.cargoFilename '
32
+ atom .config .observe ' linter-rust.cargoManifestFilename ' , =>
33
+ @cargoManifestFilename = atom .config .get ' linter-rust.cargoMainifestFilename '
34
34
atom .config .observe ' linter-rust.lintOnChange' , =>
35
35
@lintOnChange = atom .config .get ' linter-rust.lintOnChange'
36
36
@@ -51,7 +51,7 @@ class LinterRust extends Linter
51
51
52
52
initCmd : =>
53
53
@cmd = [@rustcPath , ' -Z' , ' no-trans' , ' --color' , ' never' ]
54
- cargoPath = do @locateCargo
54
+ cargoPath = do @locateCargoManifest
55
55
if cargoPath
56
56
@cmd .push ' -L'
57
57
@cmd .push path .join cargoPath, @dependencyDir
@@ -70,17 +70,10 @@ class LinterRust extends Linter
70
70
super fileName, callback
71
71
72
72
73
- locateCargo : ->
74
- directory = path .resolve path .dirname do @editor .getPath
75
- root_dir = if / ^ win/ .test process .platform then / ^ . :\\ $ / else / ^ \/ $ /
76
- loop
77
- cargoFile = path .join directory, @cargoFilename
78
- return directory if fs .existsSync cargoFile
73
+ locateCargoManifest : ->
74
+ cur_dir = path .resolve path .dirname do @editor .getPath
75
+ return findFile (cur_dir, @cargoManifestFilename )
79
76
80
- break if root_dir .test directory
81
- directory = path .resolve path .join directory, ' ..'
82
-
83
- return false
84
77
85
78
processMessage : (message , callback ) ->
86
79
if @tmpFile
0 commit comments