mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Expose platform-arch of vendored binaries #2928
This commit is contained in:
parent
9755629cfd
commit
3da258f6fb
@ -52,6 +52,17 @@ An Object containing the version numbers of libvips and its dependencies.
|
||||
console.log(sharp.versions);
|
||||
```
|
||||
|
||||
## vendor
|
||||
|
||||
An Object containing information about the platform and architecture
|
||||
of the current and installed vendored binaries.
|
||||
|
||||
### Examples
|
||||
|
||||
```javascript
|
||||
console.log(sharp.vendor);
|
||||
```
|
||||
|
||||
## cache
|
||||
|
||||
Gets or, when options are provided, sets the limits of *libvips'* operation cache.
|
||||
|
@ -21,6 +21,9 @@ Requires libvips v8.12.1
|
||||
[#2789](https://github.com/lovell/sharp/pull/2789)
|
||||
[@kleisauke](https://github.com/kleisauke)
|
||||
|
||||
* Expose platform and architecture of vendored binaries as `sharp.vendor`.
|
||||
[#2928](https://github.com/lovell/sharp/issues/2928)
|
||||
|
||||
* Ensure 16-bit PNG output uses correct bitdepth.
|
||||
[#2958](https://github.com/lovell/sharp/pull/2958)
|
||||
[@gforge](https://github.com/gforge)
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const events = require('events');
|
||||
const detectLibc = require('detect-libc');
|
||||
|
||||
@ -47,7 +49,22 @@ let versions = {
|
||||
};
|
||||
try {
|
||||
versions = require(`../vendor/${versions.vips}/${platformAndArch}/versions.json`);
|
||||
} catch (err) {}
|
||||
} catch (_err) { /* ignore */ }
|
||||
|
||||
/**
|
||||
* An Object containing the platform and architecture
|
||||
* of the current and installed vendored binaries.
|
||||
* @member
|
||||
* @example
|
||||
* console.log(sharp.vendor);
|
||||
*/
|
||||
const vendor = {
|
||||
current: platformAndArch,
|
||||
installed: []
|
||||
};
|
||||
try {
|
||||
vendor.installed = fs.readdirSync(path.join(__dirname, `../vendor/${versions.vips}`));
|
||||
} catch (_err) { /* ignore */ }
|
||||
|
||||
/**
|
||||
* Gets or, when options are provided, sets the limits of _libvips'_ operation cache.
|
||||
@ -176,5 +193,6 @@ module.exports = function (Sharp) {
|
||||
Sharp.format = format;
|
||||
Sharp.interpolators = interpolators;
|
||||
Sharp.versions = versions;
|
||||
Sharp.vendor = vendor;
|
||||
Sharp.queue = queue;
|
||||
};
|
||||
|
@ -131,4 +131,13 @@ describe('Utilities', function () {
|
||||
assert.strictEqual('string', typeof sharp.versions.vips);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Vendor', function () {
|
||||
it('Contains expected attributes', function () {
|
||||
assert.strictEqual('object', typeof sharp.vendor);
|
||||
assert.strictEqual('string', typeof sharp.vendor.current);
|
||||
assert.strictEqual(true, Array.isArray(sharp.vendor.installed));
|
||||
assert.strictEqual(true, sharp.vendor.installed.length > 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user