forked from LedgerHQ/lib-ledger-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ rewrote the preinstall.py in js so the library can be installed without python requirement + integrate PR LedgerHQ#29 + fixes installation of the library on windows. At least on Travis it was failing with python error (some SSL errors)
- Loading branch information
Showing
4 changed files
with
211 additions
and
45 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
var request = require('request') | ||
const { libcoreVersion } = require('./package.json') | ||
|
||
const perPlatform = { | ||
linux: { | ||
dir: 'linux', | ||
files: ['libledger-core.so'], | ||
chmod: 0o755, | ||
}, | ||
darwin: { | ||
dir: 'macos', | ||
files: ['libledger-core.dylib'], | ||
chmod: 0o755, | ||
}, | ||
win32: { | ||
dir: 'win/vs2015', | ||
file: ['ledger-core.dll', 'ledger-core.lib', 'crypto.dll'], | ||
}, | ||
} | ||
|
||
const conf = perPlatform[process.platform] | ||
if (!conf) { | ||
console.error(`Platform ${process.platform} is not supported`) | ||
process.exit(1) | ||
} | ||
const endpointURL = `https://s3-eu-west-1.amazonaws.com/ledger-lib-ledger-core/${libcoreVersion}/${ | ||
conf.dir | ||
}` | ||
|
||
if (!fs.existsSync('lib')) { | ||
fs.mkdirSync('lib') | ||
} | ||
|
||
conf.files.reduce( | ||
(p, file) => | ||
p.then(() => | ||
get(file).then(() => { | ||
if (conf.chmod) { | ||
fs.chmodSync(`lib/${file}`, conf.chmod) | ||
} | ||
}), | ||
), | ||
Promise.resolve(), | ||
) | ||
|
||
function get(file) { | ||
return new Promise((resolve, reject) => { | ||
const dest = `lib/${file}` | ||
if (process.env.LEDGER_CORE_LOCAL_BUILD) { | ||
const src = path.join(process.env.LEDGER_CORE_LOCAL_BUILD, file) | ||
console.log(`Copy ${src} -> ${dest}`) | ||
fs.copyFile(src, dest, err => { | ||
if (err) reject(err) | ||
else resolve() | ||
}) | ||
} else { | ||
const url = `${endpointURL}/${file}` | ||
console.log(`Downloading ${url} ...`) | ||
const f = fs.createWriteStream(dest) | ||
f.on('finish', () => { | ||
console.log(`${file} downloaded.`) | ||
f.close(resolve) | ||
}) | ||
request | ||
.get(url) | ||
.on('error', err => { | ||
fs.unlink(dest) | ||
reject(err) | ||
}) | ||
.pipe(f) | ||
} | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.