@@ -4,6 +4,7 @@ import * as Path from 'path';
44import * as fs from 'fs' ;
55import { Subject } from 'rxjs' ;
66import { FtpEntry , FTPFolder } from './ftp-entry' ;
7+ import { ConsoleOutput } from './ConsoleOutput' ;
78import moment = require( 'moment' ) ;
89
910export class FtpManager {
@@ -39,7 +40,7 @@ export class FtpManager {
3940 this . gotTo ( path ) . then ( ( ) => {
4041 this . onReady ( ) ;
4142 } ) . catch ( ( error ) => {
42- console . log ( 'ERROR: ' + error ) ;
43+ ConsoleOutput . error ( 'ERROR: ' + error ) ;
4344 this . onConnectionFailed ( ) ;
4445 } ) ;
4546 } ) ;
@@ -77,7 +78,7 @@ export class FtpManager {
7778 public async gotTo ( path : string ) {
7879 return new Promise < void > ( ( resolve , reject ) => {
7980 if ( this . isReady ) {
80- console . log ( `open ${ path } ` ) ;
81+ ConsoleOutput . info ( `open ${ path } ` ) ;
8182 this . _client . cd ( path ) . then ( ( ) => {
8283 this . _client . pwd ( ) . then ( ( dir ) => {
8384 this . currentDirectory = dir ;
@@ -148,7 +149,7 @@ export class FtpManager {
148149 newFolder . sortEntries ( ) ;
149150 result . addEntry ( newFolder ) ;
150151 counter ++ ;
151- console . log ( `${ folder . path } added, ${ counter } /${ folders . length } ` ) ;
152+ ConsoleOutput . log ( `${ folder . path } added, ${ counter } /${ folders . length } ` ) ;
152153 } ) . catch ( ( error ) => {
153154 folder . readable = false ;
154155 result . addEntry ( folder ) ;
@@ -171,7 +172,7 @@ export class FtpManager {
171172 public async downloadFolder ( remotePath : string , downloadPath : string ) {
172173 this . recursives ++ ;
173174 if ( ( this . recursives % 10 ) === 9 ) {
174- console . log ( `% wait 2 seconds...% `) ;
175+ ConsoleOutput . info ( ` wait 2 seconds...`) ;
175176 await this . wait ( 2000 ) ;
176177 }
177178
@@ -188,7 +189,7 @@ export class FtpManager {
188189 try {
189190 await this . downloadFolder ( folderPath , Path . join ( downloadPath , fileInfo . name ) ) ;
190191 this . statistics . folders ++ ;
191- console . log ( `${ this . getCurrentTimeString ( ) } ===> Directory downloaded: ${ remotePath } \n` ) ;
192+ ConsoleOutput . success ( `${ this . getCurrentTimeString ( ) } ===> Directory downloaded: ${ remotePath } \n` ) ;
192193 } catch ( e ) {
193194 this . error . next ( e ) ;
194195 }
@@ -201,7 +202,6 @@ export class FtpManager {
201202 }
202203 }
203204 }
204- console . log ( `return!` ) ;
205205 return ;
206206 } catch ( e ) {
207207 this . error . next ( e ) ;
@@ -223,7 +223,7 @@ export class FtpManager {
223223 }
224224 procentStr += procent . toFixed ( 2 ) ;
225225
226- console . log ( `${ this . getCurrentTimeString ( ) } ---> ${ info . type } (${ procentStr } %): ${ info . name } ` ) ;
226+ ConsoleOutput . log ( `${ this . getCurrentTimeString ( ) } ---> ${ info . type } (${ procentStr } %): ${ info . name } ` ) ;
227227 } ;
228228
229229 if ( this . _client . closed ) {
@@ -257,7 +257,6 @@ export class FtpManager {
257257 } ) ;
258258 }
259259
260-
261260 public getCurrentTimeString ( ) : string {
262261 const duration = Date . now ( ) - this . statistics . started ;
263262 return moment ( ) . format ( 'L LTS' ) + ' | Duration: ' + this . getTimeString ( duration ) + ' ' ;
@@ -298,7 +297,7 @@ export class FtpManager {
298297 return Math . floor ( timespan / 1000 / 60 / 60 ) ;
299298 }
300299
301- public async wait ( time : number ) : Promise < void > {
300+ public async wait ( time : number ) : Promise < void > {
302301 return new Promise < void > ( ( resolve ) => {
303302 setTimeout ( ( ) => {
304303 resolve ( ) ;
0 commit comments