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

feat: add support for mirror #72

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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,8 +3,10 @@ import process from 'node:process';
import {fileURLToPath} from 'node:url';
import BinWrapper from 'bin-wrapper';

const binaryHost = process.env.npm_config_mozjpeg_binary_host || 'https://raw.githubusercontent.com/imagemin/mozjpeg-bin';

const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
const url = `https://raw.githubusercontent.com/imagemin/mozjpeg-bin/v${pkg.version}/vendor/`;
const url = `${binaryHost}/v${pkg.version}/vendor/`;

const binWrapper = new BinWrapper()
.src(`${url}macos/cjpeg`, 'darwin')
Expand Down
5 changes: 5 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ You probably want [`imagemin-mozjpeg`](https://github.com/imagemin/imagemin-mozj
$ npm install mozjpeg
```

### Mirror

Add `npm_config_mozjpeg_binary_host` to environment variables can modify the default binary download host. Default to: `https://raw.githubusercontent.com/imagemin/mozjpeg-bin`

For example: `npm_config_mozjpeg_binary_host=https://foo.bar npm i mozjepg-bin`

## Usage

Expand Down