@@ -21,7 +21,7 @@ import { ChildProcess } from 'child_process';
21
21
import * as fs from 'fs' ;
22
22
import * as os from 'os' ;
23
23
import * as path from 'path' ;
24
- import * as request from 'request ' ;
24
+ import fetch from 'node-fetch ' ;
25
25
// @ts -ignore
26
26
import * as tmp from 'tmp' ;
27
27
@@ -57,25 +57,29 @@ export abstract class Emulator {
57
57
const writeStream : fs . WriteStream = fs . createWriteStream ( filepath ) ;
58
58
59
59
console . log ( `Downloading emulator from [${ this . binaryUrl } ] ...` ) ;
60
- request ( this . binaryUrl )
61
- . pipe ( writeStream )
62
- . on ( 'finish' , ( ) => {
63
- console . log ( `Saved emulator binary file to [${ filepath } ].` ) ;
64
- // Change emulator binary file permission to 'rwxr-xr-x'.
65
- // The execute permission is required for it to be able to start
66
- // with 'java -jar'.
67
- fs . chmod ( filepath , 0o755 , err => {
68
- if ( err ) reject ( err ) ;
69
- console . log ( `Changed emulator file permissions to 'rwxr-xr-x'.` ) ;
70
- this . binaryPath = filepath ;
71
-
72
- if ( this . copyToCache ( ) ) {
73
- console . log ( `Cached emulator at ${ this . cacheBinaryPath } ` ) ;
74
- }
75
- resolve ( ) ;
76
- } ) ;
77
- } )
78
- . on ( 'error' , reject ) ;
60
+ fetch ( this . binaryUrl ) . then ( resp => {
61
+ resp . body
62
+ . pipe ( writeStream )
63
+ . on ( 'finish' , ( ) => {
64
+ console . log ( `Saved emulator binary file to [${ filepath } ].` ) ;
65
+ // Change emulator binary file permission to 'rwxr-xr-x'.
66
+ // The execute permission is required for it to be able to start
67
+ // with 'java -jar'.
68
+ fs . chmod ( filepath , 0o755 , err => {
69
+ if ( err ) reject ( err ) ;
70
+ console . log (
71
+ `Changed emulator file permissions to 'rwxr-xr-x'.`
72
+ ) ;
73
+ this . binaryPath = filepath ;
74
+
75
+ if ( this . copyToCache ( ) ) {
76
+ console . log ( `Cached emulator at ${ this . cacheBinaryPath } ` ) ;
77
+ }
78
+ resolve ( ) ;
79
+ } ) ;
80
+ } )
81
+ . on ( 'error' , reject ) ;
82
+ } ) ;
79
83
} ) ;
80
84
} ) ;
81
85
}
0 commit comments