Skip to content

Commit

Permalink
Fix patterns with the same are overwritten on the zip.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Feb 16, 2024
1 parent b31e143 commit fb6d19f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ export const exportJSONaction = {
'application/json'
);
}
const nameCount = {};
const filesToZip = items.map( ( item ) => {
const name = kebabCase( item.title || item.name );
nameCount[ name ] = ( nameCount[ name ] || 0 ) + 1;
return {
name: `${ kebabCase( item.title || item.name ) }.json`,
name: `${
name +
( nameCount[ name ] > 1 ? '-' + nameCount[ name ] : '' )
}.json`,
lastModified: new Date(),
input: getJsonFromItem( item ),
};
Expand Down

0 comments on commit fb6d19f

Please sign in to comment.