Skip to content

Commit

Permalink
Merge pull request #5 from Palapapaa/exclude-file
Browse files Browse the repository at this point in the history
fix(input): Exclude folders to source directory
  • Loading branch information
nivekcode authored Dec 10, 2019
2 parents 4584a43 + d2878a7 commit 493815f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/lib/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@ export const convert = async (convertionOptions: ConvertionOptions): Promise<voi
let types = getTypeDefinition(convertionOptions.typeName);

try {
const files = await readdir(directoryPath);
const files = await readdir(directoryPath, { withFileTypes: true });
for (let i = 0; i < files.length; i++) {
const fileNameWithEnding = files[i];
const filenameWithoutEnding = fileNameWithEnding.split('.')[0];
const rawSvg = await extractSvgContent(fileNameWithEnding, directoryPath);
const optimizedSvg = await svgo.optimize(rawSvg);
const variableName = getVariableName(convertionOptions, filenameWithoutEnding);
i === files.length - 1
? (types += `'${snakeCase(filenameWithoutEnding)}';`)
: (types += `'${snakeCase(filenameWithoutEnding)}' | `);
svgConstants += getSvgConstant(
variableName,
convertionOptions.interfaceName,
snakeCase(filenameWithoutEnding),
optimizedSvg.data
);
if (files[i].isFile()) {
const fileNameWithEnding = files[i].name;
const filenameWithoutEnding = fileNameWithEnding.split('.')[0];
const rawSvg = await extractSvgContent(fileNameWithEnding, directoryPath);
const optimizedSvg = await svgo.optimize(rawSvg);
const variableName = getVariableName(convertionOptions, filenameWithoutEnding);
i === files.length - 1
? (types += `'${snakeCase(filenameWithoutEnding)}';`)
: (types += `'${snakeCase(filenameWithoutEnding)}' | `);
svgConstants += getSvgConstant(
variableName,
convertionOptions.interfaceName,
snakeCase(filenameWithoutEnding),
optimizedSvg.data
);
}
}
const fileContent = generateFileContent(svgConstants, types, convertionOptions);
await writeIconsFile(convertionOptions, fileContent);
Expand Down

0 comments on commit 493815f

Please sign in to comment.