mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve experience for those using Apple M1 devices #2460
- For Rosetta x64, prevent use of global ARM64 libvips - For ARM64, improve error message when global libvips not found
This commit is contained in:
@@ -37,6 +37,15 @@ const cachePath = function () {
|
||||
return libvipsCachePath;
|
||||
};
|
||||
|
||||
const isRosetta = function () {
|
||||
/* istanbul ignore next */
|
||||
if (process.platform === 'darwin' && process.arch === 'x64') {
|
||||
const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;
|
||||
return (translated || '').trim() === 'sysctl.proc_translated: 1';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const globalLibvipsVersion = function () {
|
||||
if (process.platform !== 'win32') {
|
||||
const globalLibvipsVersion = spawnSync(`PKG_CONFIG_PATH="${pkgConfigPath()}" pkg-config --modversion vips-cpp`, spawnSyncOptions).stdout;
|
||||
@@ -82,7 +91,10 @@ const useGlobalLibvips = function () {
|
||||
if (Boolean(env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (isRosetta()) {
|
||||
return false;
|
||||
}
|
||||
const globalVipsVersion = globalLibvipsVersion();
|
||||
return !!globalVipsVersion && /* istanbul ignore next */
|
||||
semver.gte(globalVipsVersion, minimumLibvipsVersion);
|
||||
|
||||
Reference in New Issue
Block a user