Skip to content

Commit

Permalink
fix: init
Browse files Browse the repository at this point in the history
  • Loading branch information
gronxb committed Sep 14, 2024
1 parent e546060 commit 1873ee1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
2 changes: 0 additions & 2 deletions src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ export const add = async (iconName: string) => {
} else {
console.error(error);
}
} finally {
s.stop("Icon generated");
}
};
78 changes: 38 additions & 40 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,45 @@ import { initConfig } from "../utils/config";
import { log } from "../utils/console";

export const init = async () => {
async () => {
const config = await p.group(
{
typescript: () =>
p.confirm({
message: "Would you like to enable TypeScript support?",
}),
path: () =>
p.text({
message: "Specify the directory for storing icons:",
placeholder: "assets/icons",
initialValue: "assets/icons",
}),
const config = await p.group(
{
typescript: () =>
p.confirm({
message: "Would you like to enable TypeScript support?",
}),
path: () =>
p.text({
message: "Specify the directory for storing icons:",
placeholder: "assets/icons",
initialValue: "assets/icons",
}),
},
{
onCancel: ({ results }) => {
p.cancel("cancelled.");
process.exit(0);
},
{
onCancel: ({ results }) => {
p.cancel("cancelled.");
process.exit(0);
},
}
);
}
);

try {
initConfig({
...config,
icons: [],
});
log.success("Project initialized successfully.");
log.success(
"Use `npx react-native-icons-builder add <icon-name>` to add an icon."
);
log.link(
"Click here to explore available icons",
"https://react-icons.github.io/react-icons/"
);
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
} else {
console.error(error);
}
try {
initConfig({
...config,
icons: [],
});
log.success("Project initialized successfully.");
log.success(
"Use `npx react-native-icons-builder add <icon-name>` to add an icon."
);
log.link(
"Click here to explore available icons",
"https://react-icons.github.io/react-icons/"
);
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
} else {
console.error(error);
}
};
}
};
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { dependencies, version } from "@/package.json";
import { program } from "commander";
import pc from "picocolors";
import { generateIcon } from "./generateIcon";
import { init } from "./commands/init";
import { add } from "./commands/add";

Expand Down

0 comments on commit 1873ee1

Please sign in to comment.