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" ;
22
33import { handleError } from "@/shared/index" ;
44import { commandSet } from "@/setup" ;
55
66import { version } from "../package.json" ;
77
8+ function welcome ( cli : CAC ) {
9+ cli . outputHelp ( ) ;
10+ }
11+
812export const setupCli = async ( ) => {
913 const cli = cac ( "cg" ) ;
1014
@@ -15,7 +19,16 @@ export const setupCli = async () => {
1519 cli . help ( ) ;
1620 cli . version ( version ) ;
1721
22+ cli . on ( "command:!" , ( ) => {
23+ welcome ( cli ) ;
24+ } ) ;
25+
26+ cli . on ( "command:*" , ( ) => {
27+ welcome ( cli ) ;
28+ } ) ;
29+
1830 cli . parse ( process . argv , { run : false } ) ;
31+
1932 await cli . runMatchedCommand ( ) ;
2033} ;
2134
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ import { npmRegistry } from "./command/npm-registry";
2424import { createProject } from "./command/create-project" ;
2525
2626export const commandSet : CommandSet = {
27+ defaultCmd : ( cli : CAC ) => {
28+ cli . command ( "" ) ;
29+ } ,
2730 gitCommitCmd : ( cli : CAC ) => {
2831 cli
2932 . command ( "commit" , "生成 angualr 规范的提交信息" )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export class PrettyError extends Error {
3030}
3131
3232export function handleError ( error : unknown ) {
33- if ( error instanceof PrettyError ) loggerError ( error ) ;
33+ if ( error instanceof PrettyError ) printError ( error ) ;
3434 process . exitCode = 1 ;
3535}
3636
You can’t perform that action at this time.
0 commit comments