Skip to content

Commit 204f788

Browse files
also filter components with underscore
1 parent a33de1a commit 204f788

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
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.filterComponentStartingWithDot(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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ const createFolder = async (path) => {
4444
}
4545
};
4646

47-
const filterComponentStartingWithDot = svgs => svgs.filter(({ name }) => !name.startsWith('.'))
47+
const filterPrivateComponents = svgs => svgs.filter(({ name }) => !name.startsWith('.') && !name.startsWith('_'))
4848

4949
exports.writeToFile = writeToFile;
5050
exports.camelCaseToDash = camelCaseToDash;
5151
exports.flattenArray = flattenArray;
5252
exports.findAllByValue = findAllByValue;
5353
exports.createFolder = createFolder;
54-
exports.filterComponentStartingWithDot = filterComponentStartingWithDot;
54+
exports.filterPrivateComponents = filterPrivateComponents;

src/util/utils.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ describe("Flatten Array", () => {
2020
});
2121
});
2222

23-
describe('Filter Components Starting With a Dot', () => {
24-
it('should remove components out of the list that start with a dot', () => {
25-
expect(Utils.filterComponentStartingWithDot([
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' },
2627
{ id: '798:3672', name: '.downhill_skiing' },
2728
{ id: '798:3671', name: 'edit_notifications' },
2829
{ id: '798:3663', name: '.elderly' },

0 commit comments

Comments
 (0)