File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const svgExporter = async () => {
2929 process . env . FIGMA_PROJECT_NODE_ID
3030 ] . document . children ;
3131
32- const svgs = Utils . findAllByValue ( children , "COMPONENT" ) ;
32+ const svgs = Utils . filterPrivateComponents ( Utils . findAllByValue ( children , "COMPONENT" ) ) ;
3333 const numOfSvgs = svgs . length ;
3434
3535 console . log ( "Number of SVGs" , numOfSvgs ) ;
Original file line number Diff line number Diff line change @@ -44,8 +44,11 @@ const createFolder = async (path) => {
4444 }
4545} ;
4646
47+ const filterPrivateComponents = svgs => svgs . filter ( ( { name } ) => ! name . startsWith ( '.' ) && ! name . startsWith ( '_' ) )
48+
4749exports . writeToFile = writeToFile ;
4850exports . camelCaseToDash = camelCaseToDash ;
4951exports . flattenArray = flattenArray ;
5052exports . findAllByValue = findAllByValue ;
5153exports . createFolder = createFolder ;
54+ exports . filterPrivateComponents = filterPrivateComponents ;
Original file line number Diff line number Diff line change @@ -19,3 +19,18 @@ describe("Flatten Array", () => {
1919 expect ( Utils . flattenArray ( array , 2 ) ) . toEqual ( result ) ;
2020 } ) ;
2121} ) ;
22+
23+ describe ( 'Filter Private Components ' , ( ) => {
24+ it ( 'should remove components out of the list that start with a dot or underscore' , ( ) => {
25+ expect ( Utils . filterPrivateComponents ( [
26+ { id : '798:3673' , name : '_circle' } ,
27+ { id : '798:3672' , name : '.downhill_skiing' } ,
28+ { id : '798:3671' , name : 'edit_notifications' } ,
29+ { id : '798:3663' , name : '.elderly' } ,
30+ { id : '798:3673' , name : 'emoji_emotions' } ,
31+ ] ) ) . toEqual ( [
32+ { id : '798:3671' , name : 'edit_notifications' } ,
33+ { id : '798:3673' , name : 'emoji_emotions' } ,
34+ ] )
35+ } )
36+ } )
You can’t perform that action at this time.
0 commit comments