opencrater 0.2.3 → 0.2.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.
- package/cli.js +9 -9
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -133,17 +133,17 @@ function enableIn(file, host) {
|
|
|
133
133
|
matcher: "",
|
|
134
134
|
hooks: [{ type: "command", command: cmdFor(event, host) }],
|
|
135
135
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
// Remove EVERY entry of ours, then add exactly one. findIndex+replace only
|
|
137
|
+
// fixed the first match, so repeated installs / older command shapes left
|
|
138
|
+
// duplicate opencrater-hook entries piling up. Filtering collapses them.
|
|
139
|
+
const others = list.filter((r) => !isOurs(r));
|
|
140
|
+
const mine = list.filter(isOurs);
|
|
141
|
+
const alreadyCorrect =
|
|
142
|
+
mine.length === 1 && JSON.stringify(mine[0]) === JSON.stringify(desired);
|
|
143
|
+
if (!alreadyCorrect) {
|
|
144
|
+
settings.hooks[event] = [...others, desired];
|
|
144
145
|
changed = true;
|
|
145
146
|
}
|
|
146
|
-
settings.hooks[event] = list;
|
|
147
147
|
}
|
|
148
148
|
if (changed) writeJson(file, settings);
|
|
149
149
|
return changed;
|