1- import type { ExtendedSourceItem } from '../ExtendedSourceItem.ts' ;
21import { cloneExtendedSourceItem } from '../ExtendedSourceItem.ts' ;
32import type { FileCollection } from '../FileCollection.ts' ;
43import { cloneFileItem } from '../FileItem.ts' ;
@@ -10,20 +9,16 @@ export function appendFileCollection(
109 other : FileCollection ,
1110 subPath : string ,
1211) {
13- const sanitizedSubPath = normalizeRelativePath ( subPath ) . replace ( / \/ $ / , '' ) ;
14- const otherSourcesToSelfSources = new Map <
15- ExtendedSourceItem [ 'uuid' ] ,
16- ExtendedSourceItem [ 'uuid' ]
17- > ( ) ;
12+ const sanitizedSubPath = normalizeRelativePath ( subPath )
13+ // trim ending slash
14+ . replace ( / \/ $ / , '' ) ;
1815
1916 for ( const otherSource of other . sources ) {
2017 const source = cloneExtendedSourceItem ( otherSource ) ;
21- source . uuid = crypto . randomUUID ( ) ;
22- source . originalRelativePath = source . relativePath ;
18+ source . originalRelativePath ??= source . relativePath ;
2319 source . relativePath = normalizeRelativePath (
2420 `${ sanitizedSubPath } /${ source . relativePath } ` ,
2521 ) ;
26- otherSourcesToSelfSources . set ( otherSource . uuid , source . uuid ) ;
2722
2823 self . sources . push ( source ) ;
2924 }
@@ -38,11 +33,6 @@ export function appendFileCollection(
3833 }
3934 const file = cloneFileItem ( otherFile ) ;
4035 file . relativePath = relativePath ;
41- const sourceUUID = otherSourcesToSelfSources . get ( file . sourceUUID ) ;
42- if ( ! sourceUUID ) {
43- throw new Error ( 'Unreachable: sourceUUID should be defined' ) ;
44- }
45- file . sourceUUID = sourceUUID ;
4636
4737 self . files . push ( file ) ;
4838 }
0 commit comments