@bgd-labs/toolbox 0.0.24 → 0.0.25
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/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -2
- package/dist/index.mjs.map +1 -1
- package/dist/node.js +19 -1
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +20 -2
- package/dist/node.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28576,7 +28576,25 @@ async function diffCode(before, after) {
|
|
|
28576
28576
|
])
|
|
28577
28577
|
);
|
|
28578
28578
|
for (const [name, path, source] of contractsBefore) {
|
|
28579
|
-
const
|
|
28579
|
+
const matchingIndexes = contractsAfter.reduce((acc, val, i) => {
|
|
28580
|
+
if (val[0] === name) acc.push(i);
|
|
28581
|
+
return acc;
|
|
28582
|
+
}, []);
|
|
28583
|
+
let indexAfter = -1;
|
|
28584
|
+
if (matchingIndexes.length === 1) {
|
|
28585
|
+
indexAfter = matchingIndexes[0];
|
|
28586
|
+
} else if (matchingIndexes.length > 1) {
|
|
28587
|
+
let maxSimilarity = -1;
|
|
28588
|
+
for (const idx of matchingIndexes) {
|
|
28589
|
+
const afterSource = contractsAfter[idx][2];
|
|
28590
|
+
const diff = (0, import_diff.diffChars)(source, afterSource);
|
|
28591
|
+
const similarity = diff.reduce((acc, part) => acc + (part.added || part.removed ? 0 : part.count || part.value.length), 0);
|
|
28592
|
+
if (similarity > maxSimilarity) {
|
|
28593
|
+
maxSimilarity = similarity;
|
|
28594
|
+
indexAfter = idx;
|
|
28595
|
+
}
|
|
28596
|
+
}
|
|
28597
|
+
}
|
|
28580
28598
|
if (indexAfter === -1) {
|
|
28581
28599
|
changes[name] = (0, import_diff.createPatch)(path, source, "");
|
|
28582
28600
|
} else {
|