@monotykamary/localterm-server 1.16.2 → 1.16.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff-watcher.d.ts","sourceRoot":"","sources":["../src/git-diff-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"git-diff-watcher.d.ts","sourceRoot":"","sources":["../src/git-diff-watcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqC3C,UAAU,oBAAoB;IAC5B,WAAW,EAAE,EAAE,CAAC;CACjB;AAED,qBAAa,cAAe,SAAQ,YAAY,CAAC,oBAAoB,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,QAAQ,CAAS;IAEzB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAgCxB,IAAI,IAAI,IAAI;IAeZ,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,aAAa;CAQtB"}
|
package/dist/git-diff-watcher.js
CHANGED
|
@@ -3,28 +3,35 @@ import path from "node:path";
|
|
|
3
3
|
import { EventEmitter } from "node:events";
|
|
4
4
|
import { GIT_DIRTY_THROTTLE_MS } from "./constants.js";
|
|
5
5
|
const resolveGitDir = (cwd) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
let current = path.resolve(cwd);
|
|
7
|
+
while (true) {
|
|
8
|
+
const indicator = path.join(current, ".git");
|
|
9
|
+
try {
|
|
10
|
+
const stat = fs.statSync(indicator);
|
|
11
|
+
if (stat.isDirectory())
|
|
12
|
+
return { gitDir: indicator, repoRoot: current };
|
|
13
|
+
if (stat.isFile()) {
|
|
14
|
+
const content = fs.readFileSync(indicator, "utf8").trim();
|
|
15
|
+
const match = /^gitdir:\s*(.+)$/m.exec(content);
|
|
16
|
+
if (match) {
|
|
17
|
+
const resolved = path.resolve(current, match[1]);
|
|
18
|
+
try {
|
|
19
|
+
if (fs.statSync(resolved).isDirectory())
|
|
20
|
+
return { gitDir: resolved, repoRoot: current };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
/* gitdir path is stale or inaccessible */
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
catch {
|
|
29
|
+
/* .git doesn't exist here — walk up */
|
|
30
|
+
}
|
|
31
|
+
const parent = path.dirname(current);
|
|
32
|
+
if (parent === current)
|
|
33
|
+
break;
|
|
34
|
+
current = parent;
|
|
28
35
|
}
|
|
29
36
|
return null;
|
|
30
37
|
};
|
|
@@ -34,21 +41,13 @@ export class GitDiffWatcher extends EventEmitter {
|
|
|
34
41
|
disposed = false;
|
|
35
42
|
start(cwd) {
|
|
36
43
|
this.stop();
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
44
|
+
const result = resolveGitDir(cwd);
|
|
45
|
+
if (!result)
|
|
39
46
|
return;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
try {
|
|
43
|
-
if (fs.statSync(refsDir).isDirectory())
|
|
44
|
-
watchTargets.push(refsDir);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
/* refs dir may not exist in a bare or unusual repo */
|
|
48
|
-
}
|
|
49
|
-
for (const target of watchTargets) {
|
|
47
|
+
const { gitDir, repoRoot } = result;
|
|
48
|
+
const watch = (target, options) => {
|
|
50
49
|
try {
|
|
51
|
-
const watcher = fs.watch(target, (event) => {
|
|
50
|
+
const watcher = fs.watch(target, options ?? {}, (event) => {
|
|
52
51
|
if (this.disposed)
|
|
53
52
|
return;
|
|
54
53
|
if (event === "change" || event === "rename") {
|
|
@@ -60,6 +59,16 @@ export class GitDiffWatcher extends EventEmitter {
|
|
|
60
59
|
catch {
|
|
61
60
|
/* target doesn't exist or isn't watchable */
|
|
62
61
|
}
|
|
62
|
+
};
|
|
63
|
+
watch(gitDir);
|
|
64
|
+
watch(repoRoot, { recursive: true });
|
|
65
|
+
const refsDir = path.join(gitDir, "refs");
|
|
66
|
+
try {
|
|
67
|
+
if (fs.statSync(refsDir).isDirectory())
|
|
68
|
+
watch(refsDir);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
/* refs dir may not exist in a bare or unusual repo */
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
stop() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-diff-watcher.js","sourceRoot":"","sources":["../src/git-diff-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"git-diff-watcher.js","sourceRoot":"","sources":["../src/git-diff-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,MAAM,aAAa,GAAG,CAAC,GAAW,EAAuB,EAAE;IACzD,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM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