Skip to content

Commit f5819e5

Browse files
committed
(diff) Fixed problems with extraction of modified lines from diff.
1 parent dc831cc commit f5819e5

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

index.js

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const diffLineNumbers = require("./tools/diff-line-numbers");
88
const parseDiff = require("./tools/parse-diff");
99
const compareDiff = require("./tools/compare-diff");
1010

11-
const WORKING_DIR = process.env.WORKING_DIR;
11+
const NYC_OUTPUT_LOCATION = process.env.NYC_OUTPUT_LOCATION;
1212

1313
const DIFF_LOCATION = __dirname + "/branch.diff";
1414

15-
diffLineNumbers(process.stdin, fs.createWriteStream(), () => {
15+
diffLineNumbers(process.stdin, fs.createWriteStream(DIFF_LOCATION), () => {
1616
parseDiff(DIFF_LOCATION)
1717
.then(compareDiff)
1818
.then(exitWithSuccess())

tools/parse-diff.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ module.exports = path => {
1010
const lines = chunk.split("\n");
1111
if (chunk && lines && lines[0] && lines[0] !== "") {
1212
const filePathFromRoot = lines[0].replace(/(diff --git )(a\/)|(b\/.*)/gi, "").split(" ")[0];
13-
const diffLines = chunk.match(/[0-9]+(\s)+:\s\+/gi);
13+
const diffLines = chunk.match(/[0-9]+(\s){0,}\:(\+)/gi);
1414
if (diffLines && diffLines instanceof Array) {
1515
let lineNumbers;
1616
try {
1717
lineNumbers = diffLines.map(l => parseInt(l.replace(/(\s)+(:)/g, "")));
1818
} catch (err) {
1919
exitWithFailure("An error occured while parsing diff for line numbers.")(err);
2020
}
21-
// eslint-disable-next-line security/detect-object-injection
2221
map.push([filePathFromRoot, lineNumbers]);
2322
}
2423
}

0 commit comments

Comments
 (0)