Skip to content

Commit

Permalink
fix(generation): fix generated folder name
Browse files Browse the repository at this point in the history
  • Loading branch information
nivekcode committed Mar 4, 2020
1 parent e884054 commit 680f1f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/lib/converters/multiple-files.converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { compileSources } from '../compiler/typescript-compiler';
import { info, success } from '../helpers/log-helper';
import { svgOptimizer } from '../helpers/svg-optimization';

const generateIconsFolderName = 'build';

export const convertToMultipleFiles = async (convertionOptions: ConvertionOptions): Promise<void> => {
const { prefix, delimiter, outputDirectory, srcFiles } = convertionOptions;
let indexFileContent = '';
Expand All @@ -35,15 +37,15 @@ export const convertToMultipleFiles = async (convertionOptions: ConvertionOption
const typeName = generateTypeName(filenameWithoutEnding, delimiter);
const svgConstant = generateUntypedSvgConstant(variableName, typeName, optimizedSvg.data);
const generatedFileName = `${prefix}-${filenameWithoutEnding}.icon`;
indexFileContent += generateExportStatement(generatedFileName);
await writeFile(`${outputDirectory}/icons`, generatedFileName, svgConstant);
info(`write file svg: ${outputDirectory}/icons/${generatedFileName}.ts`);
indexFileContent += generateExportStatement(generatedFileName, generateIconsFolderName);
await writeFile(`${outputDirectory}/${generateIconsFolderName}`, generatedFileName, svgConstant);
info(`write file svg: ${outputDirectory}/${generateIconsFolderName}/${generatedFileName}.ts`);
}
}
await writeFile(outputDirectory, 'index', indexFileContent);
info(`write index.ts`);
const generatedTypeScriptFilePaths = await getFilePathsFromRegex([
`${outputDirectory}/icons/*.ts`,
`${outputDirectory}/${generateIconsFolderName}/*.ts`,
`${outputDirectory}/index.ts`
]);
compileSources(generatedTypeScriptFilePaths);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/generators/code-snippet-generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export const generateSvgStandaloneFile = (
};`;
};

export const generateExportStatement = (fileName: string) => `export * from './icons/${fileName}';`;
export const generateExportStatement = (fileName: string, generateIconsFolderName: string) =>
`export * from './${generateIconsFolderName}/${fileName}';`;

export const generateTypeName = (filenameWithoutEnding, delimiter: Delimiter): string => {
if (delimiter === Delimiter.CAMEL) {
Expand Down

0 comments on commit 680f1f1

Please sign in to comment.