build.mjs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { buildJsIcons } from '../../.build/build-icons.mjs';
  2. import prettier from '@prettier/sync';
  3. const componentTemplate = ({ type, name, namePascal, children }) => {
  4. const nodes = JSON.stringify(Array.isArray(children) ? children : [children]);
  5. return prettier.format(
  6. `import { TablerIcon } from '../types';
  7. const ${namePascal}: TablerIcon = {
  8. name: '${name}',
  9. type: '${type}',
  10. nodes: ${nodes}
  11. };
  12. export default ${namePascal};`,
  13. { singleQuote: true, printWidth: 120, parser: 'typescript' });
  14. };
  15. const indexItemTemplate = ({
  16. _,
  17. namePascal
  18. }) => `export { default as ${namePascal}} from './${namePascal}';`;
  19. const aliasTemplate = ({ fromPascal, toPascal }) => `export { default as Icon${fromPascal}} from './icons/Icon${toPascal}';\n`;
  20. buildJsIcons({
  21. name: 'icons-angular',
  22. componentTemplate,
  23. indexItemTemplate,
  24. aliasTemplate,
  25. indexFile: 'index.ts',
  26. pascalCase: true,
  27. extension: 'ts',
  28. pretty: false
  29. });