bin-wrapper
bin-wrapper copied to clipboard
Ability to specify base url
Adds the ability to specify a base url to use when performing configuration.
This allows you to follow the following pattern:
const BinWrapper = require('bin-wrapper');
const bin = new BinWrapper()
.baseUrl('https://github.com/imagemin/gifsicle-bin/raw/master/vendor')
.src(`/linux/x64/gifsicle`, 'linux', 'x64')
.src(`/linux/x86/gifsicle`, 'linux', 'x86')
.dest(path.join('vendor'))
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle')
Additionally added the ability for developers to allow for this base url to be easily configured when this library is used to expose a binary.
For example, in the below example when the GIFSICLE_BIN__MIRROR
env var is set, this will be used as the base location from which to perform the download:
const BinWrapper = require('bin-wrapper');
const bin = new BinWrapper()
.baseUrl('https://github.com/imagemin/gifsicle-bin/raw/master/vendor')
.baseUrlOverrideEnvName('GIFSICLE_BIN__MIRROR')
.src(`/linux/x64/gifsicle`, 'linux', 'x64')
.dest(path.join('vendor'))
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle')
This allows for developers to easily add support for configuring the binary download location, this allows developers to easily support 3rd party binary mirrors and cases where due to security considerations downloading from an external source can not be considered.
Hi @sindresorhus,
Sorry to chase but keen to get this issue looked at, in order to make changes on projects which use this as a dependency,
Hi @sindresorhus , could you please review and merge this PR ? We can only use internal network due to security consideration.
+1
we should add support with npm_config_<env_name>