diff --git a/lib/index.js b/lib/index.js index 26a686c..43d049a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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') diff --git a/readme.md b/readme.md index 56ae471..06f3796 100644 --- a/readme.md +++ b/readme.md @@ -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