File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -66,21 +66,22 @@ module.exports = require('coa').Cmd()
6666 . then ( function ( source ) {
6767 if ( opts . clean ) return tocClean ( source ) ;
6868
69- if ( source . indexOf ( TOC_COMMENT ) === - 1 ) return 'NO TOC COMMENT' ;
69+ if ( source . indexOf ( TOC_COMMENT ) === - 1 ) {
70+ log . noTocCommentErr ( ) ;
71+ process . exit ( 1 ) ;
72+ }
7073
7174 var options = _ . pick ( opts , [ 'maxDepth' , 'bullet' ] ) ;
7275 return tocInsert ( source , options ) ;
76+ } , function ( ) {
77+ log . noFileErr ( args . source ) ;
78+ process . exit ( 1 ) ;
7379 } )
7480 . then ( function ( res ) {
75- if ( res === 'NO TOC COMMENT' ) return log . noTocCommentErr ( ) ;
76-
7781 return vfs . write ( target , res )
7882 . then ( function ( ) {
7983 opts . clean ? log . successCleanMsg ( ) : log . successInsertMsg ( ) ;
8084 } ) ;
81- } )
82- . fail ( function ( err ) {
83- console . log ( err ) ;
8485 } ) ;
8586 } )
8687 . run ( process . argv . slice ( 2 ) ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ module.exports = {
1111 } ,
1212
1313 noTocCommentErr : function ( ) {
14- console . log ( 'A TOC generation ' + 'failed' . bold . red +
14+ console . error ( 'A TOC generation ' + 'failed' . bold . red +
1515 '. Can not find the HTML comment ' + '<!-- TOC -->' . bold . red + '.' ) ;
16+ } ,
17+
18+ noFileErr : function ( filepath ) {
19+ console . error ( 'A TOC generation ' + 'failed' . bold . red +
20+ '. Can not open file ' + filepath . underline + '.' ) ;
1621 }
1722} ;
You can’t perform that action at this time.
0 commit comments