@oh-my-pi/pi-git-tool 3.25.0 → 3.31.0
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/utils.ts +2 -18
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -14,22 +14,6 @@ export interface ExecOptions {
|
|
|
14
14
|
timeout?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async function readStream(stream: ReadableStream<Uint8Array> | undefined): Promise<string> {
|
|
18
|
-
if (!stream) return "";
|
|
19
|
-
const reader = stream.getReader();
|
|
20
|
-
const chunks: Uint8Array[] = [];
|
|
21
|
-
try {
|
|
22
|
-
while (true) {
|
|
23
|
-
const { done, value } = await reader.read();
|
|
24
|
-
if (done) break;
|
|
25
|
-
chunks.push(value);
|
|
26
|
-
}
|
|
27
|
-
} finally {
|
|
28
|
-
reader.releaseLock();
|
|
29
|
-
}
|
|
30
|
-
return Buffer.concat(chunks).toString();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
17
|
export async function exec(command: string, args: string[], options?: ExecOptions): Promise<ExecResult> {
|
|
34
18
|
const cwd = options?.cwd ?? process.cwd();
|
|
35
19
|
const proc: Subprocess = Bun.spawn([command, ...args], {
|
|
@@ -71,8 +55,8 @@ export async function exec(command: string, args: string[], options?: ExecOption
|
|
|
71
55
|
}
|
|
72
56
|
|
|
73
57
|
const [stdout, stderr, exitCode] = await Promise.all([
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
(proc.stdout as ReadableStream<Uint8Array>).text(),
|
|
59
|
+
(proc.stderr as ReadableStream<Uint8Array>).text(),
|
|
76
60
|
proc.exited,
|
|
77
61
|
]);
|
|
78
62
|
|