@jeremyy_prt/cc-config 1.1.2 → 1.1.3
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import type { StatuslineConfig } from "../statusline.config";
|
|
4
4
|
import { defaultConfig } from "../statusline.config";
|
|
@@ -18,6 +18,21 @@ import { saveSession } from "./lib/spend";
|
|
|
18
18
|
import type { HookInput } from "./lib/types";
|
|
19
19
|
import { getUsageLimits } from "./lib/usage-limits";
|
|
20
20
|
|
|
21
|
+
// Fonction pour lire stdin de manière compatible Node.js et Bun
|
|
22
|
+
async function getStdin(): Promise<string> {
|
|
23
|
+
// Si Bun est disponible, utiliser Bun.stdin
|
|
24
|
+
if (typeof Bun !== "undefined") {
|
|
25
|
+
return await Bun.stdin.text();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Sinon, utiliser process.stdin (Node.js)
|
|
29
|
+
const chunks: Buffer[] = [];
|
|
30
|
+
for await (const chunk of process.stdin) {
|
|
31
|
+
chunks.push(chunk as Buffer);
|
|
32
|
+
}
|
|
33
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
function buildFirstLine(
|
|
22
37
|
branch: string,
|
|
23
38
|
dirPath: string,
|
|
@@ -122,7 +137,8 @@ function buildThirdLine(
|
|
|
122
137
|
|
|
123
138
|
async function main() {
|
|
124
139
|
try {
|
|
125
|
-
const
|
|
140
|
+
const stdinData = await getStdin();
|
|
141
|
+
const input: HookInput = JSON.parse(stdinData);
|
|
126
142
|
|
|
127
143
|
await saveSession(input);
|
|
128
144
|
|