From ed36faae9dcd03f1fbf5bbbf859c706e63ae24c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Tue, 15 Apr 2025 21:18:13 +0200 Subject: [PATCH] Bump `image-size` from 1.0.2 to 2.0.2 (#41384) --- package-lock.json | 21 ++++----------------- package.json | 2 +- site/src/components/head/Social.astro | 2 +- site/src/libs/image.ts | 9 ++++++--- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4d2ec27a1..61a68c6891 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "globby": "^14.1.0", "hammer-simulator": "0.0.1", "htmlparser2": "^10.0.0", - "image-size": "^1.0.2", + "image-size": "^2.0.2", "ip": "^2.0.1", "jasmine": "^5.6.0", "jquery": "^3.7.1", @@ -9450,14 +9450,11 @@ "license": "ISC" }, "node_modules/image-size": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-1.2.0.tgz", - "integrity": "sha512-4S8fwbO6w3GeCVN6OPtA9I5IGKkcDMPcKndtUlpJuCwu7JLjtj7JZpwqLuyY2nrmQT3AWsCJLSKPsc2mPBSl3w==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/image-size/-/image-size-2.0.2.tgz", + "integrity": "sha512-IRqXKlaXwgSMAMtpNzZa1ZAe8m+Sa1770Dhk8VkSsP9LS+iHD62Zd8FQKs8fbPiagBE7BzoFX23cxFnwshpV6w==", "dev": true, "license": "MIT", - "dependencies": { - "queue": "6.0.2" - }, "bin": { "image-size": "bin/image-size.js" }, @@ -14949,16 +14946,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/queue": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz", - "integrity": "sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "inherits": "~2.0.3" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", diff --git a/package.json b/package.json index 215d0e8e75..ed9a31ab02 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "globby": "^14.1.0", "hammer-simulator": "0.0.1", "htmlparser2": "^10.0.0", - "image-size": "^1.0.2", + "image-size": "^2.0.2", "ip": "^2.0.1", "jasmine": "^5.6.0", "jquery": "^3.7.1", diff --git a/site/src/components/head/Social.astro b/site/src/components/head/Social.astro index 2e423c7bb3..8f02f86fb4 100644 --- a/site/src/components/head/Social.astro +++ b/site/src/components/head/Social.astro @@ -14,7 +14,7 @@ interface Props { const { description, layout, thumbnail, title } = Astro.props const socialImageUrl = new URL(getVersionedDocsPath(`assets/${thumbnail}`), Astro.site) -const socialImageSize = getStaticImageSize(`/docs/[version]/assets/${thumbnail}`) +const socialImageSize = await getStaticImageSize(`/docs/[version]/assets/${thumbnail}`) --- diff --git a/site/src/libs/image.ts b/site/src/libs/image.ts index 7de95db501..7935222703 100644 --- a/site/src/libs/image.ts +++ b/site/src/libs/image.ts @@ -1,11 +1,14 @@ import path from 'node:path' +import { promises as fs } from 'node:fs' import sizeOf from 'image-size' import { getDocsStaticFsPath } from './path' -export function getStaticImageSize(imagePath: string) { - const size = sizeOf(path.join(getDocsStaticFsPath(), imagePath)) +export async function getStaticImageSize(imagePath: string) { + const fullPath = path.join(getDocsStaticFsPath(), imagePath) + const buffer = await fs.readFile(fullPath) + const size = await sizeOf(buffer) - if (!size.height || !size.width) { + if (!size?.height || !size?.width) { throw new Error(`Failed to get size of static image at '${imagePath}'.`) }