mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-03-21 17:54:13 -05:00
Added mkdirp() helper to app/common/fs.mjs that wraps
fs.mkdir(dir, { recursive: true }). Updated all call sites to use it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
535 B
JavaScript
22 lines
535 B
JavaScript
import fs from 'fs/promises';
|
|
import { mkdirp } from '../../common/fs.mjs';
|
|
import Client from './Client.mjs';
|
|
|
|
export default class ImageWriter extends Client {
|
|
key = 'image';
|
|
name = 'ImageWriter';
|
|
|
|
dir = 'dist/status-screenshots'; // `/screenshots` points to the page used by puppeteer
|
|
|
|
async send(status, generator) {
|
|
if (!status.media?.length) {
|
|
return;
|
|
}
|
|
|
|
await mkdirp(this.dir);
|
|
|
|
let imgFilename = `${this.dir}/${generator.key}.png`;
|
|
await fs.writeFile(imgFilename, status.media[0].file);
|
|
}
|
|
}
|