This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
chore: Allow fetching cross-platform parity-ethereum #501
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,19 +18,28 @@ const exec = promisify(require('child_process').exec); | |
const fsChmod = promisify(chmod); | ||
const fsWriteFile = promisify(writeFile); | ||
|
||
let os; | ||
switch (process.platform) { | ||
case 'win32': | ||
os = 'windows'; | ||
break; | ||
case 'darwin': | ||
os = 'darwin'; | ||
break; | ||
default: | ||
os = 'linux'; | ||
function getOs () { | ||
if (process.argv.includes('--win')) { | ||
return 'windows'; | ||
} | ||
if (process.argv.includes('--mac')) { | ||
return 'darwin'; | ||
} | ||
if (process.argv.includes('--linux')) { | ||
return 'linux'; | ||
} | ||
|
||
switch (process.platform) { | ||
case 'win32': | ||
return 'windows'; | ||
case 'darwin': | ||
return 'darwin'; | ||
default: | ||
return 'linux'; | ||
} | ||
} | ||
|
||
const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${os}&architecture=x86_64`; | ||
const ENDPOINT = `https://vanity-service.parity.io/parity-binaries?os=${getOs()}&architecture=x86_64`; | ||
|
||
const STATIC_DIRECTORY = path.join( | ||
'..', | ||
|
@@ -48,6 +57,11 @@ if (foundPath) { | |
// Bundled Parity was found, we check if the version matches the minimum requirements | ||
getBinaryVersion(foundPath) | ||
.then(version => { | ||
if (!version) { | ||
console.log("Couldn't get bundled Parity Ethereum version."); | ||
return downloadParity(); | ||
} | ||
|
||
if (!semver.satisfies(version, versionRequirement)) { | ||
console.log( | ||
'Bundled Parity Ethereum %s is older than required version %s', | ||
|
@@ -137,14 +151,19 @@ function downloadParity () { | |
}) | ||
.then(getBinaryVersion) | ||
.then(bundledVersion => | ||
console.log(`Success: bundled Parity Ethereum ${bundledVersion}`) | ||
console.log( | ||
`Success: bundled Parity Ethereum ${bundledVersion || | ||
"(couldn't get version)"}` | ||
) | ||
) | ||
); | ||
} | ||
|
||
function getBinaryVersion (binaryPath) { | ||
return exec(`${binaryPath} --version`).then(({ stdout, stderr }) => { | ||
if (stderr) throw new Error(stderr); | ||
return stdout.match(/v\d+\.\d+\.\d+/)[0]; | ||
}); | ||
return exec(`${binaryPath} --version`) | ||
.then(({ stdout, stderr }) => { | ||
if (stderr) throw new Error(stderr); | ||
return stdout.match(/v\d+\.\d+\.\d+/)[0]; | ||
}) | ||
.catch(error => console.warn(error.message)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe in the future add a note to explain that we're catching the error so that the process still exits with 0 when fetching&packaging the windows binary on linux (ci) (then, the binary version cannot be checked) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 also remove the annoying "command failed" messages |
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, in the future it can use some more commenting, otherwise the underlying logic isn't very clear