@@ -17,12 +17,12 @@ function cleanPath(path) {
1717}
1818
1919function transformAndSave ( files , mode , maxHeaderLevel , title , notitle , entryPrefix , stdOut ) {
20- console . log ( '\n==================\n' ) ;
20+ ( stdOut ) ? console . error ( '\n==================\n' ) : console . log ( '\n==================\n' )
2121
2222 var transformed = files
2323 . map ( function ( x ) {
2424 var content = fs . readFileSync ( x . path , 'utf8' )
25- , result = transform ( content , mode , maxHeaderLevel , title , notitle , entryPrefix ) ;
25+ , result = transform ( content , mode , maxHeaderLevel , title , notitle , entryPrefix , stdOut ) ;
2626 result . path = x . path ;
2727 return result ;
2828 } ) ;
@@ -41,9 +41,7 @@ function transformAndSave(files, mode, maxHeaderLevel, title, notitle, entryPref
4141 } ) ;
4242
4343 changed . forEach ( function ( x ) {
44- if ( stdOut ) {
45- console . log ( '==================\n\n"%s" was not updated.' , x . path )
46- } else {
44+ if ( ! stdOut ) {
4745 console . log ( '"%s" will be updated.' , x . path ) ;
4846 fs . writeFileSync ( x . path , x . data , 'utf8' ) ;
4947 }
@@ -107,14 +105,26 @@ for (var i = 0; i < argv._.length; i++) {
107105 , stat = fs . statSync ( target )
108106
109107 if ( stat . isDirectory ( ) ) {
110- console . log ( '\nDocToccing "%s" and its sub directories for %s.' , target , mode ) ;
108+ if ( ! stdOut ) {
109+ console . log ( '\nDocToccing "%s" and its sub directories for %s.' , target , mode ) ;
110+ } else {
111+ console . error ( '\nDocToccing "%s" and its sub directories for %s.' , target , mode ) ;
112+ }
111113 files = file . findMarkdownFiles ( target ) ;
112114 } else {
113- console . log ( '\nDocToccing single file "%s" for %s.' , target , mode ) ;
115+ if ( ! stdOut ) {
116+ console . log ( '\nDocToccing single file "%s" for %s.' , target , mode ) ;
117+ } else {
118+ console . error ( '\nDocToccing single file "%s" for %s.' , target , mode ) ;
119+ }
114120 files = [ { path : target } ] ;
115121 }
116122
117123 transformAndSave ( files , mode , maxHeaderLevel , title , notitle , entryPrefix , stdOut ) ;
118124
119- console . log ( '\nEverything is OK.' ) ;
125+ if ( ! stdOut ) {
126+ console . log ( '\nEverything is OK.' ) ;
127+ } else {
128+ console . error ( '\nEverything is OK.' ) ;
129+ }
120130}
0 commit comments