mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Allow yarn locator hash calc to fail e.g. Windows
This commit is contained in:
parent
1592f96b7b
commit
a584ae093e
@ -101,9 +101,13 @@ const isRosetta = () => {
|
||||
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);
|
||||
try {
|
||||
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
||||
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
||||
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
||||
} catch {}
|
||||
/* istanbul ignore next */
|
||||
return '';
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
@ -147,7 +147,9 @@ describe('libvips binaries', function () {
|
||||
|
||||
it('yarn locator hash', () => {
|
||||
const locatorHash = libvips.yarnLocator();
|
||||
assert.strictEqual(locatorHash.length, 10);
|
||||
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
||||
if (locatorHash.length) {
|
||||
assert.strict(locatorHash.length, 10);
|
||||
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user