watskeburt 5.0.0-beta-3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/git-primitives.js +8 -14
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/git-primitives.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
const SHA1_LENGTH = 40;
|
|
3
|
+
const EMPTY_ERROR_MAP = new Map([]);
|
|
3
4
|
export async function getStatusShort(pSpawnFunction = spawn) {
|
|
4
5
|
const lErrorMap = new Map([
|
|
5
6
|
[129, `'${process.cwd()}' does not seem to be a git repository`],
|
|
@@ -35,7 +36,7 @@ export async function getDiffLines(
|
|
|
35
36
|
export async function getSHA(pSpawnFunction = spawn) {
|
|
36
37
|
const lRevParseOutput = await getGitResult(
|
|
37
38
|
["rev-parse", "HEAD"],
|
|
38
|
-
|
|
39
|
+
EMPTY_ERROR_MAP,
|
|
39
40
|
pSpawnFunction,
|
|
40
41
|
);
|
|
41
42
|
return lRevParseOutput.slice(0, SHA1_LENGTH);
|
|
@@ -45,23 +46,23 @@ function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
|
|
|
45
46
|
cwd: process.cwd(),
|
|
46
47
|
env: process.env,
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const lStdOutChunks = [];
|
|
50
|
+
const lStdErrorChunks = [];
|
|
50
51
|
return new Promise((pResolve, pReject) => {
|
|
51
52
|
lGit.stdout?.on("data", (pData) => {
|
|
52
|
-
|
|
53
|
+
lStdOutChunks.push(pData);
|
|
53
54
|
});
|
|
54
55
|
lGit.stderr?.on("data", (pData) => {
|
|
55
|
-
|
|
56
|
+
lStdErrorChunks.push(pData);
|
|
56
57
|
});
|
|
57
58
|
lGit.on("close", (pCode) => {
|
|
58
59
|
if (pCode === 0) {
|
|
59
|
-
pResolve(
|
|
60
|
+
pResolve(lStdOutChunks.join(""));
|
|
60
61
|
} else {
|
|
61
62
|
pReject(
|
|
62
63
|
new Error(
|
|
63
64
|
pErrorMap.get(pCode ?? 0) ??
|
|
64
|
-
`internal git error: ${pCode} (${
|
|
65
|
+
`internal git error: ${pCode} (${lStdErrorChunks.join("")})`,
|
|
65
66
|
),
|
|
66
67
|
);
|
|
67
68
|
}
|
|
@@ -75,10 +76,3 @@ function getGitResult(pArguments, pErrorMap, pSpawnFunction) {
|
|
|
75
76
|
});
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
|
-
function stringifyOutStream(pBufferOrString) {
|
|
79
|
-
if (pBufferOrString instanceof Buffer) {
|
|
80
|
-
return pBufferOrString.toString("utf8");
|
|
81
|
-
} else {
|
|
82
|
-
return pBufferOrString;
|
|
83
|
-
}
|
|
84
|
-
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "5.0.
|
|
1
|
+
export const VERSION = "5.0.1";
|