@@ -6,9 +6,10 @@ let BbPromise = require('bluebird'),
6
6
path = require ( 'path' ) ,
7
7
http = require ( 'http' ) ,
8
8
fs = require ( 'fs' ) ;
9
+
9
10
10
- let download = function ( source , destination ) {
11
- let createDir = function ( path ) {
11
+ let download = function ( source , destination , spinner ) {
12
+ let createDir = function ( path ) {
12
13
if ( ! fs . existsSync ( path ) ) {
13
14
fs . mkdirSync ( path ) ;
14
15
}
@@ -23,7 +24,7 @@ let download = function (source, destination) {
23
24
let len = parseInt ( redirectResponse . headers [ 'content-length' ] , 10 ) ,
24
25
cur = 0 ,
25
26
total = len / 1048576 ; //1048576 - bytes in 1Megabyte
26
- console . log ( "Downloading dynamodb local (Size " + total . toFixed ( 2 ) + " mb). This is one-time operation and can take several minutes ..." ) ;
27
+ console . log ( "Downloading dynamodb local (Size " + total . toFixed ( 2 ) + " mb). This is one-time operation and can take several minutes ..." ) ;
27
28
if ( 200 != redirectResponse . statusCode ) {
28
29
reject ( new Error ( 'Error getting DynamoDb local latest tar.gz location ' + response . headers . location + ': ' + redirectResponse . statusCode ) ) ;
29
30
}
@@ -33,14 +34,15 @@ let download = function (source, destination) {
33
34
path : destination
34
35
} ) )
35
36
. on ( 'end' , function ( ) {
37
+ spinner . stop ( true ) ;
36
38
console . log ( "Installation complete ..." ) ;
37
39
resolve ( ) ;
38
40
} )
39
41
. on ( 'error' , function ( err ) {
40
42
reject ( err ) ;
41
43
} ) . on ( "data" , function ( chunk ) {
42
44
cur += chunk . length ;
43
- process . stdout . write ( "Downloading " + ( 100.0 * cur / len ) . toFixed ( 2 ) + "% \r" ) ;
45
+ // process.stdout.write("Downloading " + (100.0 * cur / len).toFixed(2) + "% \r");
44
46
} ) ;
45
47
} )
46
48
. on ( 'error' , function ( e ) {
@@ -53,13 +55,14 @@ let download = function (source, destination) {
53
55
} ) ;
54
56
} ;
55
57
56
- let setup = function ( dbPath , downloadPath , jar ) {
57
- return new BbPromise ( function ( resolve , reject ) {
58
+ let setup = function ( dbPath , downloadPath , jar , spinner ) {
59
+ return new BbPromise ( function ( resolve , reject ) {
58
60
try {
59
61
if ( fs . existsSync ( path . join ( dbPath , jar ) ) ) {
62
+ spinner . stop ( true ) ;
60
63
resolve ( true ) ;
61
64
} else {
62
- download ( downloadPath , dbPath ) . then ( resolve , reject ) ;
65
+ download ( downloadPath , dbPath , spinner ) . then ( resolve , reject ) ;
63
66
}
64
67
} catch ( e ) { }
65
68
} ) ;
0 commit comments