Skip to content

Commit

Permalink
feat: console
Browse files Browse the repository at this point in the history
  • Loading branch information
gronxb committed Sep 16, 2024
1 parent 47c7188 commit 8da44ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { init } from "./init";
import { log } from "../utils/console";
import { isCancel, select } from "@clack/prompts";
import { IconManager } from "src/iconManager";
import pc from "picocolors";

export const add = async (iconName: string) => {
try {
Expand Down Expand Up @@ -58,7 +59,12 @@ export const add = async (iconName: string) => {
await iconManager.addIcon(prefix as string, iconNameToUse);
await generateBaseCode(config);
await iconManager.sync();
log.success("Icon added successfully");
console.log(`${pc.green("Add")} ${iconNameToUse}`);
console.log(
pc.gray(`import { ${iconNameToUse} } from "${config.outputPath}/${prefix}";
<${iconNameToUse} size={24} />`)
);
} catch (error) {
if (error instanceof Error) {
log.error(error.message);
Expand Down
3 changes: 0 additions & 3 deletions src/utils/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export const log = {
success: (message: string) => {
console.log(pc.green(message));
},
save: (filename: string) => {
console.log(`${pc.blue(`${filename}`)} ${pc.green("saved successfully.")}`);
},
link: (message: string, link: string) => {
console.log(`\x1b]8;;${link}\x1b\\${message}\x1b]8;;\x1b\\`);
},
Expand Down
4 changes: 2 additions & 2 deletions src/utils/generateBaseCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export const generateBaseCode = async (config: Config) => {
copyFile(
path.join(templatesPath, iconBase),
path.join(outputPath, iconBase)
).then(() => log.save(path.join(config.outputPath, iconBase))),
),
copyFile(
path.join(templatesPath, iconContext),
path.join(outputPath, iconContext)
).then(() => log.save(path.join(config.outputPath, iconContext))),
),
]);
};
1 change: 0 additions & 1 deletion src/utils/saveIconCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export const saveIconCode = async (
await fs.mkdir($outputPath, { recursive: true });

await fs.writeFile(path.join($outputPath, filename), code, "utf8");
log.save(path.join(outputPath, filename));
};

0 comments on commit 8da44ee

Please sign in to comment.