Skip to content

Commit eb7e480

Browse files
committed
Format the file
1 parent 0585c9c commit eb7e480

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

lib/generate-icon-components.mjs

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
1-
import { pascalCase } from 'change-case';
1+
import { pascalCase } from "change-case";
22
import { existsSync } from "node:fs";
33
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
44
import { basename, dirname, extname, join } from "node:path";
5-
import { fileURLToPath } from 'node:url';
5+
import { fileURLToPath } from "node:url";
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

9-
const ICON_FOLDER = join(__dirname, '..', 'public', 'icons')
10-
const COMPONENT_ICON_FOLDER = join(__dirname, '..', 'addon', 'components', 'icons');
9+
const ICON_FOLDER = join(__dirname, "..", "public", "icons");
10+
const COMPONENT_ICON_FOLDER = join(
11+
__dirname,
12+
"..",
13+
"addon",
14+
"components",
15+
"icons",
16+
);
1117

1218
const files = await readdir(ICON_FOLDER);
13-
const icons = files.filter(file => extname(file) === '.svg').map(svg => basename(svg, '.svg'));
19+
const icons = files
20+
.filter((file) => extname(file) === ".svg")
21+
.map((svg) => basename(svg, ".svg"));
1422

1523
await prepareOutputDir();
1624

17-
const promises = icons.map(svg => {
25+
const promises = icons.map((svg) => {
1826
return generateComponent(svg);
1927
});
2028
await Promise.all(promises);
2129

2230
async function generateComponent(iconName) {
2331
const componentName = pascalCase(iconName);
2432

25-
const iconContent = await readFile(join(ICON_FOLDER, iconName + '.svg'));
26-
const iconContentWithAttributes = iconContent.toString().replace('>', ' ...attributes>'); // We assume the first closing element is the svg element
33+
const iconContent = await readFile(join(ICON_FOLDER, iconName + ".svg"));
34+
const iconContentWithAttributes = iconContent
35+
.toString()
36+
.replace(">", " ...attributes>"); // We assume the first closing element is the svg element
2737

2838
const component = `// THIS FILE IS GENERATED. ANY CHANGES TO THIS FILE WILL BE LOST.
2939
import type { TOC } from '@ember/component/template-only';
@@ -33,9 +43,9 @@ export interface ${componentName}IconSignature {
3343
}
3444
3545
export const ${componentName}Icon: TOC<${componentName}IconSignature> = <template>${iconContentWithAttributes}</template>;
36-
export default ${componentName}Icon;`
46+
export default ${componentName}Icon;`;
3747

38-
await writeFile(join(COMPONENT_ICON_FOLDER, iconName + '.gts'), component)
48+
await writeFile(join(COMPONENT_ICON_FOLDER, iconName + ".gts"), component);
3949
}
4050

4151
async function prepareOutputDir() {

0 commit comments

Comments
 (0)