mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-09 13:11:03 +02:00
Bump image-size
from 1.0.2 to 2.0.2 (#41384)
This commit is contained in:
@@ -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}'.`)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user