Skip to content

Commit c70c15d

Browse files
author
Guillaume MOREAU
committed
fix(types): Fix error in type generation when last item is a folder
1 parent 4a104be commit c70c15d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/convert.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ export const convert = async (convertionOptions: ConvertionOptions): Promise<voi
3030

3131
try {
3232
const files = await readdir(directoryPath, { withFileTypes: true });
33+
const typesDelimitor = ' | ';
3334
for (let i = 0; i < files.length; i++) {
3435
if (files[i].isFile()) {
3536
const fileNameWithEnding = files[i].name;
3637
const filenameWithoutEnding = fileNameWithEnding.split('.')[0];
3738
const rawSvg = await extractSvgContent(fileNameWithEnding, directoryPath);
3839
const optimizedSvg = await svgo.optimize(rawSvg);
3940
const variableName = getVariableName(convertionOptions, filenameWithoutEnding);
40-
i === files.length - 1
41-
? (types += `'${snakeCase(filenameWithoutEnding)}';`)
42-
: (types += `'${snakeCase(filenameWithoutEnding)}' | `);
41+
types += `'${snakeCase(filenameWithoutEnding)}'${typesDelimitor}`;
4342
svgConstants += getSvgConstant(
4443
variableName,
4544
convertionOptions.interfaceName,
@@ -48,6 +47,7 @@ export const convert = async (convertionOptions: ConvertionOptions): Promise<voi
4847
);
4948
}
5049
}
50+
types = types.substring(0, types.length - typesDelimitor.length) + ';';
5151
const fileContent = generateFileContent(svgConstants, types, convertionOptions);
5252
await writeIconsFile(convertionOptions, fileContent);
5353
console.log(

0 commit comments

Comments
 (0)