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

Please add environment variable to set bin download URL #34

Open
peixin opened this issue Oct 25, 2019 · 2 comments
Open

Please add environment variable to set bin download URL #34

peixin opened this issue Oct 25, 2019 · 2 comments

Comments

@peixin
Copy link

peixin commented Oct 25, 2019

like node-sass can set sass-binary-site to download bin library.

function getBinaryUrl() {
  var site = getArgument('--sass-binary-site') ||
             process.env.SASS_BINARY_SITE  ||
             process.env.npm_config_sass_binary_site ||
             (pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
             'https://github.com/sass/node-sass/releases/download';

  return [site, 'v' + pkg.version, getBinaryName()].join('/');
}

For some reason in china download from github is very slow.

We usually install package from https://npm.taobao.org/mirrors

pngquant-bin: https://npm.taobao.org/mirrors/pngquant-bin/
mozjpeg-bin: https://npm.taobao.org/mirrors/mozjpeg-bin/
cwebp-bin: https://npm.taobao.org/mirrors/cwebp-bin/

@Jamuz
Copy link

Jamuz commented Nov 25, 2019

Edit: There seems to be a related PR already for this in bin-wrapper project: kevva/bin-wrapper#73.

Environment variable for custom cwebp binary download URL would be great!

In our CI environment we do not have access to the internet, but we need to rely on our internal Artifactory contents instead. The Artifactory instance is proxying raw.githubusercontent.com, so we do have access to the binaries available in https://raw.githubusercontent.com/imagemin/cwebp-bin/v${pkg.version}/vendor/ (mentioned in cwebp-bin/lib/index.js), but at a different URL. The problem is that we cannot override the URL used in cwebp-bin/lib/index.js, so npm install fails in our CI.

As a workaround I tried to download the binary to node_modules/cwebp-bin/vendor/ directory before running npm install, but it seems that the whole node_modules/cwebp-bin directory gets removed and re-created during npm install so my downloaded cwebp binary is gone before postinstall actions.

Is there any workaround to make this working with the environment I'm working in - I can download manually all required components, but npm install fails with our current settings. Any pre-tasks I could do prior to npm install to make it pass? (I can use yum to install webp) Is it possible to somehow disable the removal of pre-downloaded vendor/cwebp when issuing npm install?

FYI: The dependency to cwebp-bin comes from

@mafrosis
Copy link

Another corporate user here looking for the same answer. An environment variable to specify the base URL is the common way to fix this.

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

No branches or pull requests

3 participants