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 sha512 = (s) => createHash('sha512').update(s).digest('hex');
|
||||||
|
|
||||||
const yarnLocator = () => {
|
const yarnLocator = () => {
|
||||||
|
try {
|
||||||
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
||||||
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`]).version;
|
||||||
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);
|
||||||
|
} catch {}
|
||||||
|
/* istanbul ignore next */
|
||||||
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
|
@ -147,7 +147,9 @@ describe('libvips binaries', function () {
|
|||||||
|
|
||||||
it('yarn locator hash', () => {
|
it('yarn locator hash', () => {
|
||||||
const locatorHash = libvips.yarnLocator();
|
const locatorHash = libvips.yarnLocator();
|
||||||
assert.strictEqual(locatorHash.length, 10);
|
if (locatorHash.length) {
|
||||||
|
assert.strict(locatorHash.length, 10);
|
||||||
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
assert.strict(/[a-f0-9]{10}/.test(locatorHash));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user