mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Install: always use Brotli-compressed tarballs
This commit is contained in:
parent
468e95427e
commit
8c6d9fdc62
@ -138,14 +138,10 @@ To install the prebuilt libvips binaries from a custom URL,
|
|||||||
set the `sharp_libvips_binary_host` npm config option
|
set the `sharp_libvips_binary_host` npm config option
|
||||||
or the `npm_config_sharp_libvips_binary_host` environment variable.
|
or the `npm_config_sharp_libvips_binary_host` environment variable.
|
||||||
|
|
||||||
The version subpath and file name are appended to these. There should be tarballs available
|
The version subpath and file name are appended to these.
|
||||||
that are compressed with both gzip and Brotli, as the format downloaded will vary depending
|
|
||||||
on whether the user's version of Node supports Brotli decompression (Node.js v10.16.0+)
|
|
||||||
|
|
||||||
For example, if `sharp_libvips_binary_host` is set to `https://hostname/path`
|
For example, if `sharp_libvips_binary_host` is set to `https://hostname/path`
|
||||||
and the libvips version is `1.2.3` then the resultant URL will be
|
and the libvips version is `1.2.3` then the resultant URL will be
|
||||||
`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.br` or
|
`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.br`.
|
||||||
`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.gz`.
|
|
||||||
|
|
||||||
See the Chinese mirror below for a further example.
|
See the Chinese mirror below for a further example.
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ const hasSharpPrebuild = [
|
|||||||
const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
|
const { minimumLibvipsVersion, minimumLibvipsVersionLabelled } = libvips;
|
||||||
const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
|
const distHost = process.env.npm_config_sharp_libvips_binary_host || 'https://github.com/lovell/sharp-libvips/releases/download';
|
||||||
const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
|
const distBaseUrl = process.env.npm_config_sharp_dist_base_url || process.env.SHARP_DIST_BASE_URL || `${distHost}/v${minimumLibvipsVersionLabelled}/`;
|
||||||
const supportsBrotli = ('BrotliDecompress' in zlib);
|
|
||||||
const installationForced = !!(process.env.npm_config_sharp_install_force || process.env.SHARP_INSTALL_FORCE);
|
const installationForced = !!(process.env.npm_config_sharp_install_force || process.env.SHARP_INSTALL_FORCE);
|
||||||
|
|
||||||
const fail = function (err) {
|
const fail = function (err) {
|
||||||
@ -68,7 +67,7 @@ const extractTarball = function (tarPath, platformAndArch) {
|
|||||||
|
|
||||||
stream.pipeline(
|
stream.pipeline(
|
||||||
fs.createReadStream(tarPath),
|
fs.createReadStream(tarPath),
|
||||||
supportsBrotli ? new zlib.BrotliDecompress() : new zlib.Gunzip(),
|
new zlib.BrotliDecompress(),
|
||||||
tarFs.extract(versionedVendorPath, { ignore }),
|
tarFs.extract(versionedVendorPath, { ignore }),
|
||||||
function (err) {
|
function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -121,10 +120,8 @@ try {
|
|||||||
handleError(new Error(`Expected Node.js version ${supportedNodeVersion} but found ${process.versions.node}`));
|
handleError(new Error(`Expected Node.js version ${supportedNodeVersion} but found ${process.versions.node}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
const extension = supportsBrotli ? 'br' : 'gz';
|
|
||||||
|
|
||||||
// Download to per-process temporary file
|
// Download to per-process temporary file
|
||||||
const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.' + extension;
|
const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.br';
|
||||||
const tarPathCache = path.join(libvips.cachePath(), tarFilename);
|
const tarPathCache = path.join(libvips.cachePath(), tarFilename);
|
||||||
if (fs.existsSync(tarPathCache)) {
|
if (fs.existsSync(tarPathCache)) {
|
||||||
libvips.log(`Using cached ${tarPathCache}`);
|
libvips.log(`Using cached ${tarPathCache}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user