@winding-labs/glow 0.1.0 → 0.1.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/lib/agents.mjs +12 -3
- package/lib/core.mjs +1 -1
- package/package.json +1 -1
package/lib/agents.mjs
CHANGED
|
@@ -70,6 +70,14 @@ function stripOurs(groups) {
|
|
|
70
70
|
.filter((g) => !(g && typeof g === 'object' && Array.isArray(g.hooks) && g.hooks.length === 0));
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
const hasHookIn = (file) => {
|
|
74
|
+
try {
|
|
75
|
+
return hasHook(readJson(file));
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
73
81
|
export const hasHook = (settings) => Array.isArray(settings?.hooks?.Stop) && settings.hooks.Stop.some((g) => Array.isArray(g?.hooks) && g.hooks.some(isOurs));
|
|
74
82
|
|
|
75
83
|
/** The file's JSON ({} when missing). Throws when it exists but isn't a JSON object, so it's never clobbered. */
|
|
@@ -83,8 +91,9 @@ export function readJson(file) {
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
/**
|
|
86
|
-
* Write next to the original with its mode kept
|
|
87
|
-
*
|
|
94
|
+
* Write next to the original with its mode kept. The original is copied to <file>.before-glow once, and only while it
|
|
95
|
+
* has no Glow hook (so the backup is always the file as it was before Glow). A symlinked settings file (dotfiles) is
|
|
96
|
+
* written through to its target, so the link stays a link.
|
|
88
97
|
*/
|
|
89
98
|
export function writeJson(file, value) {
|
|
90
99
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
@@ -93,7 +102,7 @@ export function writeJson(file, value) {
|
|
|
93
102
|
if (fs.existsSync(target)) {
|
|
94
103
|
mode = fs.statSync(target).mode & 0o777;
|
|
95
104
|
const backup = `${file}.before-glow`;
|
|
96
|
-
if (!fs.existsSync(backup)) fs.copyFileSync(target, backup);
|
|
105
|
+
if (!fs.existsSync(backup) && !hasHookIn(target)) fs.copyFileSync(target, backup);
|
|
97
106
|
}
|
|
98
107
|
writeFileAtomic(target, `${JSON.stringify(value, null, 2)}\n`, mode);
|
|
99
108
|
}
|
package/lib/core.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import fs from 'node:fs';
|
|
|
15
15
|
import os from 'node:os';
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
|
|
18
|
-
export const VERSION = '0.1.
|
|
18
|
+
export const VERSION = '0.1.1';
|
|
19
19
|
export const DEFAULT_API = 'https://app.meetglow.ai';
|
|
20
20
|
export const dir = () => path.join(os.homedir(), '.glow');
|
|
21
21
|
export const configPath = () => path.join(dir(), 'config.json');
|
package/package.json
CHANGED