Skip to content

Commit 9fc3111

Browse files
author
Guillaume MOREAU
committed
fix(conversion): check to allow only svg files
1 parent 2af8f09 commit 9fc3111

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/lib/convert.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ export const convert = async (convertionOptions: ConvertionOptions): Promise<voi
5656
for (let i = 0; i < files.length; i++) {
5757
if (files[i].isFile()) {
5858
const fileNameWithEnding = files[i].name;
59-
const filenameWithoutEnding = fileNameWithEnding.split('.')[0];
60-
const directoryPath = filesDirectoryPath[fileNameWithEnding];
61-
const rawSvg = await extractSvgContent(fileNameWithEnding, directoryPath);
62-
const optimizedSvg = await svgo.optimize(rawSvg);
63-
const variableName = getVariableName(convertionOptions, filenameWithoutEnding);
64-
const typeName = getTypeName(filenameWithoutEnding, convertionOptions.delimiter);
65-
types += `'${typeName}'${typesDelimitor}`;
66-
svgConstants += getSvgConstant(variableName, convertionOptions.interfaceName, typeName, optimizedSvg.data);
59+
const [filenameWithoutEnding, extension] = fileNameWithEnding.split('.');
60+
61+
if (extension === 'svg') {
62+
const directoryPath = filesDirectoryPath[fileNameWithEnding];
63+
const rawSvg = await extractSvgContent(fileNameWithEnding, directoryPath);
64+
const optimizedSvg = await svgo.optimize(rawSvg);
65+
const variableName = getVariableName(convertionOptions, filenameWithoutEnding);
66+
const typeName = getTypeName(filenameWithoutEnding, convertionOptions.delimiter);
67+
types += `'${typeName}'${typesDelimitor}`;
68+
svgConstants += getSvgConstant(variableName, convertionOptions.interfaceName, typeName, optimizedSvg.data);
69+
}
6770
}
6871
}
6972
types = types.substring(0, types.length - typesDelimitor.length) + ';';

0 commit comments

Comments
 (0)