diff --git a/svg-generator/__tests__/__snapshots__/create-tree.spec.ts.snap b/svg-generator/__tests__/__snapshots__/create-tree.spec.ts.snap
index c11bcd6..e735f08 100644
--- a/svg-generator/__tests__/__snapshots__/create-tree.spec.ts.snap
+++ b/svg-generator/__tests__/__snapshots__/create-tree.spec.ts.snap
@@ -20,6 +20,15 @@ exports[`createTree should create the correct tree 1`] = `
"name": "child2",
"path": "src/app/svg/group/child2.ts",
},
+ {
+ "content": "export const childCopyIcon = {
+ data: \`\`,
+ name: 'child-copy' as const
+};",
+ "identifierName": "childCopyIcon"
+ "name": "child_copy",
+ "path": "src/app/svg/group/child_copy.ts",
+ },
{
"content": "import { childIcon } from './child';
import { child2Icon } from './child2';
@@ -78,6 +87,6 @@ export const groupTwoIcons = [childOneIcon, childTwoIcon];
`;
exports[`createTree should create the type file 1`] = `
-"export declare type SvgIcons = 'foo' | 'bar' | 'foo-bar';
+"export declare type SvgIcons = 'foo' | 'bar' | 'foo-bar' | 'foo-baz';
"
`;
diff --git a/svg-generator/__tests__/create-tree.spec.ts b/svg-generator/__tests__/create-tree.spec.ts
index 468a6f4..d4e183c 100644
--- a/svg-generator/__tests__/create-tree.spec.ts
+++ b/svg-generator/__tests__/create-tree.spec.ts
@@ -13,6 +13,7 @@ describe('createTree', () => {
[`${srcPath}/group`]: {
'child.svg': ``,
'child2.svg': ``,
+ 'child_copy.svg': ``
},
[`${srcPath}/group-two`]: {
'child-one.svg': ``,
@@ -28,6 +29,6 @@ describe('createTree', () => {
});
it('should create the type file', () => {
- expect(createTypeFile(['foo', 'bar', 'foo-bar'])).toMatchSnapshot();
+ expect(createTypeFile(['foo', 'bar', 'foo-bar', 'foo_baz'])).toMatchSnapshot();
});
});
diff --git a/svg-generator/create-types.ts b/svg-generator/create-types.ts
index fb143ed..1d8a64e 100644
--- a/svg-generator/create-types.ts
+++ b/svg-generator/create-types.ts
@@ -5,9 +5,9 @@ import {
ScriptTarget,
ScriptKind,
factory,
- NodeFlags,
SyntaxKind,
} from 'typescript';
+import kebabCase from 'lodash.kebabcase';
const printer = createPrinter({
newLine: NewLineKind.LineFeed,
@@ -23,7 +23,7 @@ export function createTypeFile(names: string[]) {
undefined,
factory.createUnionTypeNode(
names.map((name) => {
- return factory.createLiteralTypeNode(factory.createStringLiteral(name, true));
+ return factory.createLiteralTypeNode(factory.createStringLiteral(kebabCase(name), true));
})
)
),