Add support for Yarn Plug'n'Play filesystem layout #3888

This commit is contained in:
Lovell Fuller
2023-12-10 19:38:03 +00:00
parent 004fff975f
commit 1592f96b7b
5 changed files with 27 additions and 5 deletions

View File

@@ -4,11 +4,12 @@
'use strict';
const { spawnSync } = require('node:child_process');
const { createHash } = require('node:crypto');
const semverCoerce = require('semver/functions/coerce');
const semverGreaterThanOrEqualTo = require('semver/functions/gte');
const detectLibc = require('detect-libc');
const { engines } = require('../package.json');
const { engines, optionalDependencies } = require('../package.json');
const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || /* istanbul ignore next */
engines.libvips;
@@ -97,6 +98,14 @@ const isRosetta = () => {
return false;
};
const sha512 = (s) => createHash('sha512').update(s).digest('hex');
const yarnLocator = () => {
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
};
/* istanbul ignore next */
const spawnRebuild = () =>
spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {
@@ -164,6 +173,7 @@ module.exports = {
buildSharpLibvipsLibDir,
runtimePlatformArch,
log,
yarnLocator,
spawnRebuild,
globalLibvipsVersion,
pkgConfigPath,