@@ -57,10 +57,8 @@ export default {
57
57
const filePath = activeEditor . getPath ( ) ;
58
58
const [ projectPath , projectRelativeFilePath ] = atom . project . relativizePath ( filePath ) ;
59
59
60
- // With the custom format the puppet-int ouput looks like this:
61
- // error mongodb::service not in autoload module layout 3 7
62
- const regexLine = / ^ ( w a r n i n g | e r r o r ) \s ( .* ) \s ( \d + ) \s ( \d + ) $ / ;
63
- const args = [ '--relative' , '--log-format' , '%{kind} %{message} %{line} %{column}' , '--error-level' , errorLevel ] ;
60
+ // Setup args
61
+ const args = [ '--relative' , '--json' , '--error-level' , errorLevel ] ;
64
62
65
63
const optionsMap = require ( './flags.js' ) ;
66
64
@@ -82,23 +80,22 @@ export default {
82
80
}
83
81
const toReturn = [ ] ;
84
82
85
- // Check for proper warnings and errors from stdout
86
- output . split ( / \r ? \n / ) . forEach ( ( line ) => {
87
- const matches = regexLine . exec ( line ) ;
88
- if ( matches != null ) {
89
- const errLine = Number . parseInt ( matches [ 3 ] , 10 ) - 1 ;
90
- const errCol = Number . parseInt ( matches [ 4 ] , 10 ) - 1 ;
83
+ // Parse JSON output
84
+ const info = JSON . parse ( output ) ;
91
85
86
+ // Check for proper warnings and errors from stdout
87
+ if ( info . length > 0 ) {
88
+ info [ 0 ] [ 0 ] . forEach ( function ( issue ) {
92
89
toReturn . push ( {
93
- severity : matches [ 1 ] ,
94
- excerpt : matches [ 2 ] ,
90
+ severity : issue . KIND ,
91
+ excerpt : issue . message ,
95
92
location : {
96
- file : filePath ,
97
- position : helpers . generateRange ( activeEditor , errLine , errCol ) ,
93
+ file : issue . path ,
94
+ position : helpers . generateRange ( activeEditor , issue . line , issue . column ) ,
98
95
} ,
99
96
} ) ;
100
- }
101
- } ) ;
97
+ } ) ;
98
+ }
102
99
return toReturn ;
103
100
} ) ;
104
101
} ,
0 commit comments