import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import os from 'node:os'; import path from 'node:path'; import test from 'node:test'; import { ensureParentDir } from './ensureParentDir'; void test('ensureParentDir: creates nested parent', async () => { const root = await fs.mkdtemp(path.join(os.tmpdir(), 'dnd-mkdir-')); try { const file = path.join(root, 'a', 'b', 'out.ttrpg.zip'); await ensureParentDir(file); const st = await fs.stat(path.dirname(file)); assert.equal(st.isDirectory(), true); } finally { await fs.rm(root, { recursive: true, force: true }); } }); void test('ensureParentDir: drive root is a no-op (Windows)', async () => { if (process.platform !== 'win32') return; // Must not throw EPERM the way fs.mkdir('E:\\') often does. await ensureParentDir('E:\\campaign.ttrpg.zip'); await ensureParentDir('C:\\file.ttrpg.zip'); });