Skip to content

Commit 4758f3c

Browse files
committed
git.ts: revert 49b15b8 (git linehandler issue)
There are some issues with this patch. Reverting to prior code pending another solution (a recent change appears to fix the problem). Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent a7206f2 commit 4758f3c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/git.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,20 @@ export function git(args: string[], options?: IGitOptions | undefined):
4545
if (!process.stdout) {
4646
throw new Error(`No stdout for "git ${args.join(" ")}`);
4747
}
48-
const promises: Array<Promise<void>> = [];
48+
let linePromise: Promise<void> | undefined;
4949
const handleLine = (line: string): boolean => {
5050
try {
51-
promises.push(lineHandler(line));
51+
if (!linePromise) {
52+
linePromise = lineHandler(line);
53+
} else {
54+
linePromise = linePromise.then(() => {
55+
return lineHandler(line);
56+
});
57+
}
58+
linePromise.catch((reason) => {
59+
reject(reason);
60+
process.kill();
61+
});
5262
} catch (reason) {
5363
reject(reason);
5464
process.kill();
@@ -74,7 +84,12 @@ export function git(args: string[], options?: IGitOptions | undefined):
7484
if (buffer.length > 0) {
7585
handleLine(buffer);
7686
}
77-
Promise.all(promises).then(() => resolve("")).catch(reject);
87+
if (linePromise) {
88+
linePromise.then(() => { resolve(""); })
89+
.catch((reason) => { reject(reason); });
90+
} else {
91+
resolve("");
92+
}
7893
});
7994
};
8095
}

0 commit comments

Comments
 (0)