1
1
2
2
exports . activate = function ( ) {
3
-
3
+
4
4
}
5
5
6
6
exports . deactivate = function ( ) {
@@ -12,8 +12,14 @@ class IssuesProvider {
12
12
return new Promise ( function ( resolve ) {
13
13
try {
14
14
const options = {
15
+ cwd : nova . workspace . path ,
15
16
args : [ "rubocop" , '--disable-pending-cops' , '-fj' , editor . document . path ]
16
17
} ;
18
+ if ( nova . config . get ( "Rubocop.bundle-exec" , "boolean" ) ) {
19
+ options . args . unshift ( "bundle" , "exec" )
20
+ }
21
+ // console.log('Config: ' + nova.config.get("Rubocop.bundle-exec", "boolean"))
22
+ // console.log("Options: " + options.args)
17
23
let rubocop = new Process ( "/usr/bin/env" , options ) ;
18
24
let rawIssues = [ ]
19
25
let issues = [ ] ;
@@ -25,24 +31,27 @@ class IssuesProvider {
25
31
'convention' : IssueSeverity . Hint ,
26
32
'info' : IssueSeverity . Info
27
33
}
28
-
29
34
rubocop . onStdout ( ( line ) => { rawIssues . push ( line ) ; } ) ;
30
- rubocop . onStderr ( ( line ) => { console . warn ( `Rubocop ERROR: ${ line } ` ) ; } ) ;
35
+ rubocop . onStderr ( ( line ) => { console . error ( `Rubocop ERROR: ${ line } ` ) ; } ) ;
31
36
rubocop . onDidExit ( ( message ) => {
32
- const allIssues = JSON . parse ( rawIssues ) [ 'files' ] [ 0 ] [ 'offenses' ] ;
33
- allIssues . forEach ( ( offense ) => {
34
- let issue = new Issue ( ) ;
35
- issue . message = offense [ 'message' ]
36
- issue . code = offense [ 'cop_name' ]
37
- issue . severity = issueSeverity [ offense [ 'severity' ] ] ;
38
- issue . column = offense [ "location" ] [ "start_column" ]
39
- issue . endColumn = offense [ "location" ] [ "end_column" ]
40
- issue . line = offense [ "location" ] [ "start_line" ]
41
- issue . endLine = offense [ "location" ] [ "end_line" ]
42
- issues . push ( issue ) ;
43
- } )
44
- resolve ( issues ) ;
45
- return ;
37
+ if ( rawIssues . length === 0 ) {
38
+ return ;
39
+ } else {
40
+ const allIssues = JSON . parse ( rawIssues ) [ 'files' ] [ 0 ] [ 'offenses' ] ;
41
+ allIssues . forEach ( ( offense ) => {
42
+ let issue = new Issue ( ) ;
43
+ issue . message = offense [ 'message' ]
44
+ issue . code = offense [ 'cop_name' ]
45
+ issue . severity = issueSeverity [ offense [ 'severity' ] ] ;
46
+ issue . column = offense [ "location" ] [ "start_column" ]
47
+ issue . endColumn = offense [ "location" ] [ "end_column" ]
48
+ issue . line = offense [ "location" ] [ "start_line" ]
49
+ issue . endLine = offense [ "location" ] [ "end_line" ]
50
+ issues . push ( issue ) ;
51
+ } )
52
+ resolve ( issues ) ;
53
+ return ;
54
+ }
46
55
} ) ;
47
56
rubocop . start ( ) ;
48
57
} catch ( error ) {
@@ -54,4 +63,4 @@ class IssuesProvider {
54
63
}
55
64
}
56
65
57
- nova . assistants . registerIssueAssistant ( "ruby" , new IssuesProvider ( ) , { event : "onChange" } ) ;
66
+ nova . assistants . registerIssueAssistant ( "ruby" , new IssuesProvider ( ) , { event : "onChange" } ) ;
0 commit comments