@@ -8,79 +8,88 @@ const { api, utils } = require('dext-core-utils');
88
99args . command ( [ 'install' , 'i' ] , 'Install a new plugin or theme.' , ( name , sub ) => {
1010 const plugin = sub [ 0 ] ;
11- const spinner = ora ( `${ plugin } : Installing...` ) . start ( ) ;
11+ const spinner = ora ( chalk . green ( `${ plugin } : Installing...` ) ) . start ( ) ;
1212 return api . install ( plugin , utils . paths . getPluginPath ( plugin ) )
1313 . then ( ( ) => {
14+ spinner . color = 'green' ;
1415 spinner . text = chalk . green ( `${ plugin } : Installed successfully!` ) ;
1516 spinner . succeed ( ) ;
1617 } )
17- . catch ( err => {
18+ . catch ( ( err ) => {
19+ spinner . color = 'red' ;
20+ spinner . text = chalk . red ( err ) ;
1821 spinner . fail ( ) ;
19- console . error ( chalk . red ( err ) ) ;
2022 } ) ;
2123} ) ;
2224
2325args . command ( [ 'uninstall' , 'u' ] , 'Uninstall a plugin or theme.' , ( name , sub ) => {
2426 const plugin = sub [ 0 ] ;
25- const spinner = ora ( `${ plugin } : Uninstalling...` ) . start ( ) ;
27+ const spinner = ora ( chalk . green ( `${ plugin } : Uninstalling...` ) ) . start ( ) ;
2628 return api . uninstall ( plugin , utils . paths . getPluginPath ( plugin ) )
2729 . then ( ( ) => {
30+ spinner . color = 'green' ;
2831 spinner . text = chalk . green ( `${ plugin } : Uninstalled successfully!` ) ;
2932 spinner . succeed ( ) ;
3033 } )
31- . catch ( err => {
34+ . catch ( ( err ) => {
35+ spinner . color = 'red' ;
36+ spinner . text = chalk . red ( err ) ;
3237 spinner . fail ( ) ;
33- console . error ( chalk . red ( err ) ) ;
3438 } ) ;
3539} ) ;
3640
3741args . command ( [ 'theme' , 't' ] , 'Sets a theme.' , ( name , sub ) => {
3842 const theme = sub [ 0 ] ;
39- const spinner = ora ( `${ theme } : setting theme...` ) . start ( ) ;
43+ const spinner = ora ( chalk . green ( `${ theme } : setting theme...` ) ) . start ( ) ;
4044 return api . setTheme ( theme )
4145 . then ( ( ) => {
46+ spinner . color = 'green' ;
4247 spinner . text = chalk . green ( `${ theme } : Theme has been set successfully!` ) ;
4348 spinner . succeed ( ) ;
4449 } )
45- . catch ( err => {
50+ . catch ( ( err ) => {
51+ spinner . color = 'red' ;
52+ spinner . text = chalk . red ( err ) ;
4653 spinner . fail ( ) ;
47- console . error ( chalk . red ( err ) ) ;
4854 } ) ;
4955} ) ;
5056
5157args . command ( [ 'link' ] , 'Creates a symlink for the current plugin.' , ( ) => {
5258 const plugin = path . basename ( process . cwd ( ) ) ;
53- const spinner = ora ( ` Linking...` ) . start ( ) ;
59+ const spinner = ora ( chalk . green ( ' Linking...' ) ) . start ( ) ;
5460 return api . createSymLink ( plugin , process . cwd ( ) )
5561 . then ( ( data ) => {
62+ spinner . color = 'green' ;
5663 spinner . text = chalk . green ( `Linked: ${ data . srcPath } -> ${ data . destPath } ` ) ;
5764 spinner . succeed ( ) ;
5865 } )
59- . catch ( err => {
66+ . catch ( ( err ) => {
67+ spinner . color = 'red' ;
68+ spinner . text = chalk . red ( err ) ;
6069 spinner . fail ( ) ;
61- console . error ( chalk . red ( err ) ) ;
6270 } ) ;
6371} ) ;
6472
6573args . command ( [ 'unlink' ] , 'Removes the symlink for the current plugin.' , ( ) => {
6674 const plugin = path . basename ( process . cwd ( ) ) ;
67- const spinner = ora ( ` Unlinking...` ) . start ( ) ;
75+ const spinner = ora ( chalk . green ( ' Unlinking...' ) ) . start ( ) ;
6876 return api . removeSymLink ( plugin )
6977 . then ( ( data ) => {
78+ spinner . color = 'green' ;
7079 spinner . text = chalk . green ( `Unlinked: ${ data . destPath } ` ) ;
7180 spinner . succeed ( ) ;
7281 } )
73- . catch ( err => {
82+ . catch ( ( err ) => {
83+ spinner . color = 'red' ;
84+ spinner . text = chalk . red ( err ) ;
7485 spinner . fail ( ) ;
75- console . error ( chalk . red ( err ) ) ;
7686 } ) ;
7787} ) ;
7888
7989args . command ( [ 'config' ] , 'Display the raw config.' , ( ) => api . getConfig ( )
80- . then ( ( data ) => {
81- console . log ( chalk . green ( JSON . stringify ( data , null , 2 ) ) ) ;
82- } )
83- . catch ( err => console . error ( chalk . red ( err ) ) ) ) ;
90+ . then ( data => console . log ( JSON . stringify ( data , null , 2 ) ) )
91+ . catch ( err => console . error ( chalk . red ( err ) ) )
92+ ) ;
8493
8594const flags = args . parse ( process . argv ) ;
8695
0 commit comments