@@ -5,7 +5,7 @@ import { getEndpointsFromFile } from "./file";
55import { Dependencies , Endpoint , Group , GroupMap } from "./types" ;
66
77// Helper function to process the tree and gather endpoints
8- export function getGroupsFromTree (
8+ export function getEndpontsFromTree (
99 tree : Dependencies ,
1010 parentFiles : string [ ] = [ ] ,
1111 endpoints : Endpoint [ ] = [ ] ,
@@ -27,25 +27,11 @@ export function getGroupsFromTree(
2727 // Recursively process the tree
2828 if ( typeof value !== "string" ) {
2929 const updatedParentFiles = [ ...parentFiles , filePath ] ;
30- getGroupsFromTree ( value , updatedParentFiles , endpoints ) ;
30+ getEndpontsFromTree ( value , updatedParentFiles , endpoints ) ;
3131 }
3232 }
3333
34- const groups : Group [ ] = [ ] ;
35-
36- for ( const endpoint of endpoints ) {
37- const group = groups . find ( ( group ) => group . name === endpoint . group ) ;
38- if ( group ) {
39- group . endpoints . push ( endpoint ) ;
40- } else {
41- groups . push ( {
42- name : endpoint . group || "" ,
43- endpoints : [ endpoint ] ,
44- } ) ;
45- }
46- }
47-
48- return groups ;
34+ return endpoints ;
4935}
5036
5137// Function to handle splitting and storing paths based on the split command logic
@@ -73,18 +59,18 @@ export function splitPath(
7359 ) ;
7460 fs . copyFileSync ( entrypointPath , entrypointCopyPath ) ;
7561
76- // Copy other files based on the dependencies, remove duplicates
77- const files = [
78- ... new Set (
79- ... group . endpoints . map ( ( endpoint ) => {
80- return [
81- endpoint . filePath ,
82- ... endpoint . parentFilePaths ,
83- ... endpoint . childrenFilePaths ,
84- ] ;
85- } ) ,
86- ) ,
87- ] ;
62+ // Copy other files based on the dependencies
63+ const endpointsFiles = group . endpoints . map ( ( endpoint ) => {
64+ return [
65+ endpoint . filePath ,
66+ ... endpoint . parentFilePaths ,
67+ ... endpoint . childrenFilePaths ,
68+ ] ;
69+ } ) ;
70+
71+ // Flatten the array and remove duplicates
72+ const files = Array . from ( new Set ( endpointsFiles . flat ( ) ) ) ;
73+
8874 for ( const filePath of files ) {
8975 const relativeFileNamePath = path . relative ( targetDir , filePath ) ;
9076 const destinationPath = path . join (
0 commit comments