File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1+ import { getConfirm } from '@/qa' ;
2+ import { useEnvVar } from '@/utils' ;
3+ import ora from 'ora' ;
4+ import VError from 'verror' ;
5+
6+ const reset = async ( ) => {
7+ const confirm = await getConfirm (
8+ 'All configuration files and cache will be deleted' ,
9+ ) ;
10+ const sp = ora ( ) ;
11+
12+ if ( ! confirm ) {
13+ sp . fail ( 'Cancel' ) ;
14+ return ;
15+ }
16+
17+ sp . start ( 'Reset' ) ;
18+ try {
19+ await fs . rm ( useEnvVar ( ) . __dir_cache , { recursive : true } ) ;
20+ } catch ( e ) {
21+ sp . fail ( `Reset fail because: ${ ( e as Error ) . message } ` ) ;
22+ throw new VError ( e ) ;
23+ }
24+ sp . succeed ( 'Done' ) ;
25+ } ;
26+
27+ export default reset ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import VError from 'verror';
66
77const errHandle = ( err : Error | VError ) => {
88 if ( err instanceof VError ) {
9- console . error ( chalk . black . bgRed ( ' ERROR ' ) , chalk . red ( err . message ) ) ;
9+ console . error ( chalk . black . bgRed ( ' ERROR ' ) , chalk . red ( err . message ) ) ;
1010 process . exit ( 0 ) ;
1111 } else {
1212 console . error ( chalk . black . bgRed ( ' UNCATCH ERROR ' ) , chalk . red ( err . stack ) ) ;
@@ -34,8 +34,11 @@ program
3434 . description ( 'Manage repository' )
3535 . action ( ( opt ) => cmdRepo ( { opt } ) ) ;
3636
37+ program . command ( 'reset' ) . action ( ( ) => reset ( ) ) ;
38+
3739program . parse ( ) ;
3840
3941import type { Hooks as _Hooks } from './Hook' ;
42+ import reset from './command/reset' ;
4043export type { InjectHook , BaseHook } from './Hook' ;
4144export type Hooks = Partial < _Hooks > ;
You can’t perform that action at this time.
0 commit comments