Expose platform-arch of vendored binaries #2928

This commit is contained in:
Lovell Fuller
2021-12-12 13:38:00 +00:00
parent 9755629cfd
commit 3da258f6fb
5 changed files with 43 additions and 2 deletions

View File

@@ -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;
};