refactor(config-protection): build targetPaths without mutation

This commit is contained in:
Brian La Plume committed 2026-10-28 12:14:38 -07:00
1 parent fbb9d34fd1
commit 2a3ed89600
1 file changed
+3 -7
+3 -7
View File
@@ -172,14 +172,10 @@ function run(inputOrRaw, options = {}) {
*/
function targetPaths(toolInput) {
const shared = toolInput?.file_path || toolInput?.file || '';
const paths = new Set();
if (typeof shared === 'string' && shared) paths.add(shared);
const edits = Array.isArray(toolInput?.edits) ? toolInput.edits : [];
for (const edit of edits) {
const entryPath = edit && typeof edit === 'object' ? edit.file_path : undefined;
if (typeof entryPath === 'string' && entryPath) paths.add(entryPath);
}
return [...paths];
const entryPaths = edits.map(edit => (edit && typeof edit === 'object' ? edit.file_path : undefined));
const candidates = [shared, ...entryPaths].filter(p => typeof p === 'string' && p);
return [...new Set(candidates)];
}
function checkTarget(filePath) {