@@ -18,19 +18,28 @@ const exec = promisify(require('child_process').exec);
1818const fsChmod = promisify ( chmod ) ;
1919const fsWriteFile = promisify ( writeFile ) ;
2020
21- let os ;
22- switch ( process . platform ) {
23- case 'win32' :
24- os = 'windows' ;
25- break ;
26- case 'darwin' :
27- os = 'darwin' ;
28- break ;
29- default :
30- os = 'linux' ;
21+ function getOs ( ) {
22+ if ( process . argv . includes ( '--win' ) ) {
23+ return 'windows' ;
24+ }
25+ if ( process . argv . includes ( '--mac' ) ) {
26+ return 'darwin' ;
27+ }
28+ if ( process . argv . includes ( '--linux' ) ) {
29+ return 'linux' ;
30+ }
31+
32+ switch ( process . platform ) {
33+ case 'win32' :
34+ return 'windows' ;
35+ case 'darwin' :
36+ return 'darwin' ;
37+ default :
38+ return 'linux' ;
39+ }
3140}
3241
33- const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${ os } &architecture=x86_64` ;
42+ const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${ getOs ( ) } &architecture=x86_64` ;
3443
3544const STATIC_DIRECTORY = path . join (
3645 '..' ,
@@ -48,6 +57,11 @@ if (foundPath) {
4857 // Bundled Parity was found, we check if the version matches the minimum requirements
4958 getBinaryVersion ( foundPath )
5059 . then ( version => {
60+ if ( ! version ) {
61+ console . log ( "Couldn't get bundled Parity Ethereum version." ) ;
62+ return downloadParity ( ) ;
63+ }
64+
5165 if ( ! semver . satisfies ( version , versionRequirement ) ) {
5266 console . log (
5367 'Bundled Parity Ethereum %s is older than required version %s' ,
@@ -137,14 +151,19 @@ function downloadParity () {
137151 } )
138152 . then ( getBinaryVersion )
139153 . then ( bundledVersion =>
140- console . log ( `Success: bundled Parity Ethereum ${ bundledVersion } ` )
154+ console . log (
155+ `Success: bundled Parity Ethereum ${ bundledVersion ||
156+ "(couldn't get version)" } `
157+ )
141158 )
142159 ) ;
143160}
144161
145162function getBinaryVersion ( binaryPath ) {
146- return exec ( `${ binaryPath } --version` ) . then ( ( { stdout, stderr } ) => {
147- if ( stderr ) throw new Error ( stderr ) ;
148- return stdout . match ( / v \d + \. \d + \. \d + / ) [ 0 ] ;
149- } ) ;
163+ return exec ( `${ binaryPath } --version` )
164+ . then ( ( { stdout, stderr } ) => {
165+ if ( stderr ) throw new Error ( stderr ) ;
166+ return stdout . match ( / v \d + \. \d + \. \d + / ) [ 0 ] ;
167+ } )
168+ . catch ( error => console . warn ( error . message ) ) ;
150169}
0 commit comments