(filePath)
| 370 | } |
| 371 | |
| 372 | function pngSize(filePath) { |
| 373 | const buffer = fs.readFileSync(filePath); |
| 374 | if ( |
| 375 | buffer.length < 24 || |
| 376 | buffer.readUInt32BE(0) !== 0x89504e47 || |
| 377 | buffer.readUInt32BE(4) !== 0x0d0a1a0a |
| 378 | ) { |
| 379 | throw new Error(`${filePath} is not a PNG file`); |
| 380 | } |
| 381 | return { |
| 382 | width: buffer.readUInt32BE(16), |
| 383 | height: buffer.readUInt32BE(20), |
| 384 | }; |
| 385 | } |
| 386 | |
| 387 | function killPortListeners(port) { |
| 388 | const result = spawnSync("lsof", ["-ti", `tcp:${port}`], { |