fix: load env before reference image backfill

This commit is contained in:
FengLee
2026-06-06 21:50:49 +08:00
parent 0ab469fee9
commit e9b1993209

View File

@@ -2,15 +2,16 @@
import fs from 'fs';
import path from 'path';
import pg from 'pg';
import referenceImageStorage from '../src/lib/reference-image-storage.ts';
const { persistReferenceImages } = referenceImageStorage;
loadEnvFile(path.join(process.cwd(), '.env.local'));
const { Client } = pg;
const args = new Set(process.argv.slice(2));
const dryRun = args.has('--dry-run');
const referenceImageStorage = await import('../src/lib/reference-image-storage.ts');
const persistReferenceImages = referenceImageStorage.persistReferenceImages
|| referenceImageStorage.default?.persistReferenceImages;
if (args.has('--check-import')) {
if (typeof persistReferenceImages !== 'function') {
throw new Error('persistReferenceImages import failed');