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

custom binary download url #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const path = require('path');
const BinWrapper = require('bin-wrapper');
const packageJson = require('../package.json');

const url = `https://raw.githubusercontent.com/imagemin/optipng-bin/v${packageJson.version}/vendor/`;
const url = process.env.OPTIPNG_BINARY_SITE ||
process.env.npm_config_optipng_binary_site ||
`https://raw.githubusercontent.com/imagemin/optipng-bin/v${packageJson.version}/vendor/`;

module.exports = new BinWrapper()
.src(`${url}macos/optipng`, 'darwin')
Expand Down
30 changes: 30 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ $ npm install --save optipng-bin
```


## Binary configuration parameters

You can configure an alternate download URL for the precompiled optipng binary. The structure should follow the following convention:

OS | URL | Architecture
--------|---------------------------------------|-------------
MacOS | http://example.com/macos/optipng | darwin
Windows | http://example.com/win/optipng.exe | win32
Linux | http://examle.com/linux/x86/optipng | x86
Linux | http://examle.com/linux/x64/optipng | x64
FreeBSD | http://examle.com/freebsd/x86/optipng | x86
FreeBSD | http://examle.com/freebsd/x64/optipng | x64
SunOS | http://examle.com/sunos/x86/optipng | x86
SunOS | http://examle.com/sunos/x64/optipng | x64

Following parameters are supported:

Variable name | .npmrc parameter | Value
--------------------|---------------------|------
OPTIPNG_BINARY_SITE | optipng_binary_site | URL

These parameters can be used as environment variable:

* E.g. `export OPTIPNG_BINARY_SITE=http://example.com/`

As local or global [.npmrc](https://docs.npmjs.com/misc/config) configuration file:

* E.g. `optipng_binary_site=http://example.com/`


## Usage

```js
Expand Down