Skip to content

Commit 22d92e6

Browse files
authored
Merge pull request #27 from borealisgroup/ignore-svgs-starting-with-dot
Ignore private components
2 parents 0437170 + 204f788 commit 22d92e6

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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);

src/util/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
4749
exports.writeToFile = writeToFile;
4850
exports.camelCaseToDash = camelCaseToDash;
4951
exports.flattenArray = flattenArray;
5052
exports.findAllByValue = findAllByValue;
5153
exports.createFolder = createFolder;
54+
exports.filterPrivateComponents = filterPrivateComponents;

src/util/utils.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
})

0 commit comments

Comments
 (0)