File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
- import cac from "cac" ;
1
+ import cac , { CAC } from "cac" ;
2
2
3
3
import { handleError } from "@/shared/index" ;
4
4
import { commandSet } from "@/setup" ;
5
5
6
6
import { version } from "../package.json" ;
7
7
8
+ function welcome ( cli : CAC ) {
9
+ cli . outputHelp ( ) ;
10
+ }
11
+
8
12
export const setupCli = async ( ) => {
9
13
const cli = cac ( "cg" ) ;
10
14
@@ -15,7 +19,16 @@ export const setupCli = async () => {
15
19
cli . help ( ) ;
16
20
cli . version ( version ) ;
17
21
22
+ cli . on ( "command:!" , ( ) => {
23
+ welcome ( cli ) ;
24
+ } ) ;
25
+
26
+ cli . on ( "command:*" , ( ) => {
27
+ welcome ( cli ) ;
28
+ } ) ;
29
+
18
30
cli . parse ( process . argv , { run : false } ) ;
31
+
19
32
await cli . runMatchedCommand ( ) ;
20
33
} ;
21
34
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ import { npmRegistry } from "./command/npm-registry";
24
24
import { createProject } from "./command/create-project" ;
25
25
26
26
export const commandSet : CommandSet = {
27
+ defaultCmd : ( cli : CAC ) => {
28
+ cli . command ( "" ) ;
29
+ } ,
27
30
gitCommitCmd : ( cli : CAC ) => {
28
31
cli
29
32
. command ( "commit" , "生成 angualr 规范的提交信息" )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export class PrettyError extends Error {
30
30
}
31
31
32
32
export function handleError ( error : unknown ) {
33
- if ( error instanceof PrettyError ) loggerError ( error ) ;
33
+ if ( error instanceof PrettyError ) printError ( error ) ;
34
34
process . exitCode = 1 ;
35
35
}
36
36
You can’t perform that action at this time.
0 commit comments