@shelken/pi-co-authored-by 0.2.13 → 0.2.14
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 +1 -1
- package/src/config.ts +0 -21
- package/src/index.ts +2 -5
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
1
|
import { readFileSync } from "node:fs";
|
|
3
2
|
import { join } from "node:path";
|
|
4
3
|
|
|
@@ -32,23 +31,3 @@ export function resolveCoAuthorEmail(
|
|
|
32
31
|
return DEFAULT_CO_AUTHOR_EMAIL;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
export function resolveHostVersion(
|
|
37
|
-
generatorName: "omp" | "pi",
|
|
38
|
-
fallbackVersion: string,
|
|
39
|
-
execFn?: (cmd: string) => string,
|
|
40
|
-
): string {
|
|
41
|
-
try {
|
|
42
|
-
const raw = execFn
|
|
43
|
-
? execFn(generatorName)
|
|
44
|
-
: execFileSync(generatorName, ["--version"], {
|
|
45
|
-
encoding: "utf8",
|
|
46
|
-
timeout: 1500,
|
|
47
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
48
|
-
});
|
|
49
|
-
const match = raw.match(/([0-9]+\.[0-9]+(?:\.[0-9]+[^\s]*)?)/);
|
|
50
|
-
return match?.[1] || fallbackVersion;
|
|
51
|
-
} catch {
|
|
52
|
-
return fallbackVersion;
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -5,12 +5,11 @@ import {
|
|
|
5
5
|
removeCommitHookDirectory,
|
|
6
6
|
wrapBashWithCommitHook,
|
|
7
7
|
} from "./commit.ts";
|
|
8
|
-
import { resolveCoAuthorEmail, resolveGeneratorName
|
|
8
|
+
import { resolveCoAuthorEmail, resolveGeneratorName } from "./config.ts";
|
|
9
9
|
import { isGitCommitCommand } from "./git-commit.ts";
|
|
10
10
|
|
|
11
11
|
export default function (pi: ExtensionAPI) {
|
|
12
12
|
let hooksDir: string | undefined;
|
|
13
|
-
let cachedHostVersion: string | undefined;
|
|
14
13
|
|
|
15
14
|
function ensureHooksDir(): string {
|
|
16
15
|
hooksDir ??= createCommitHookDirectory();
|
|
@@ -23,7 +22,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
23
22
|
|
|
24
23
|
pi.on("session_shutdown", async () => {
|
|
25
24
|
removeCommitHookDirectory(hooksDir);
|
|
26
|
-
cachedHostVersion = undefined;
|
|
27
25
|
hooksDir = undefined;
|
|
28
26
|
});
|
|
29
27
|
|
|
@@ -37,13 +35,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
37
35
|
|
|
38
36
|
const generatorName = resolveGeneratorName(CONFIG_DIR_NAME);
|
|
39
37
|
const coAuthorEmail = resolveCoAuthorEmail(CONFIG_DIR_NAME, getAgentDir());
|
|
40
|
-
cachedHostVersion ??= resolveHostVersion(generatorName, VERSION);
|
|
41
38
|
|
|
42
39
|
event.input.command = wrapBashWithCommitHook(
|
|
43
40
|
event.input.command,
|
|
44
41
|
ensureHooksDir(),
|
|
45
42
|
modelName,
|
|
46
|
-
|
|
43
|
+
VERSION,
|
|
47
44
|
{
|
|
48
45
|
generatorName,
|
|
49
46
|
coAuthorEmail,
|