-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
executable file
·43 lines (33 loc) · 929 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env node
/***
* CREATE COMPONENT CLI
* A CLI for creating new react components
*/
import fs from "fs";
import program from "commander";
import Commands from "./src/commands.js";
import { DEFAULT_TEMPLATE_DIR } from "./src/config.js";
(() => {
const commands = new Commands();
program.arguments("<cmd> [name]");
program.version("1.1.1");
program.command("help").action(() => commands.help());
program.command("info").action(() => commands.help());
program
.command("add [name]")
.option("-p, --path [path]", "overwrite the default path")
.action((name, opt) => {
commands.add(name, opt.path);
});
program.command("init").action(() => {
commands.init();
});
program.command("test").action(() => {
console.log(
JSON.parse(
fs.readFileSync(`${DEFAULT_TEMPLATE_DIR}/config.json`, "utf-8")
)
);
});
program.parse(process.argv);
})();