Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify base url #73

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ConfuddledPenguin
Copy link

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.

@ConfuddledPenguin
Copy link
Author

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,

@EscapeB
Copy link

EscapeB commented Dec 29, 2021

Hi @sindresorhus , could you please review and merge this PR ?
We can only use internal network due to security consideration.

@MondoGao
Copy link

+1

@MondoGao
Copy link

we should add support with npm_config_<env_name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants