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

Commit 69fdcd2

Browse files
committed
begin work on convert output parsing to json
1 parent 9b35ab8 commit 69fdcd2

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

lib/main.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ export default {
5757
const filePath = activeEditor.getPath();
5858
const [projectPath, projectRelativeFilePath] = atom.project.relativizePath(filePath);
5959

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 = /^(warning|error)\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];
6462

6563
const optionsMap = require('./flags.js');
6664

@@ -82,23 +80,22 @@ export default {
8280
}
8381
const toReturn = [];
8482

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);
9185

86+
// Check for proper warnings and errors from stdout
87+
if (info.length > 0) {
88+
info[0][0].forEach(function (issue) {
9289
toReturn.push({
93-
severity: matches[1],
94-
excerpt: matches[2],
90+
severity: issue.KIND,
91+
excerpt: issue.message,
9592
location: {
96-
file: filePath,
97-
position: helpers.generateRange(activeEditor, errLine, errCol),
93+
file: issue.path,
94+
position: helpers.generateRange(activeEditor, issue.line, issue.column),
9895
},
9996
});
100-
}
101-
});
97+
});
98+
}
10299
return toReturn;
103100
});
104101
},

0 commit comments

Comments
 (0)