All files / stream-counter/scripts copy-reports.js

0% Statements 0/39
0% Branches 0/1
0% Functions 0/1
0% Lines 0/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                                   
#!/usr/bin/env node
 
import { promises as fs } from "fs";
import { dirname, join } from "path";
import { fileURLToPath } from "url";
 
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
 
const sourceDir = join(__dirname, "..", "reports");
const targetDir = join(__dirname, "..", "reports-build", "reports");
const publicDir = join(__dirname, "..", "reports-build");
 
async function copyReports() {
  try {
    // reports-buildディレクトリを作成
    await fs.mkdir(publicDir, { recursive: true });
    await fs.mkdir(targetDir, { recursive: true });
 
    // reportsディレクトリが存在するかチェック
    try {
      await fs.access(sourceDir);
    } catch {
      console.log("⚠️  Reports directory not found. Please run tests first.");
      return;
    }
 
    // reportsディレクトリの内容をコピー
    const files = await fs.readdir(sourceDir);
 
    for (const file of files) {
      const sourcePath = join(sourceDir, file);
      const targetPath = join(targetDir, file);
 
      const stats = await fs.stat(sourcePath);
      if (stats.isFile()) {
        await fs.copyFile(sourcePath, targetPath);
        console.log(`✅ Copied: ${file}`);
      }
    }
 
    console.log("🎉 Reports copied successfully to reports-build/reports/");
  } catch (error) {
    console.error("❌ Error copying reports:", error);
    process.exit(1);
  }
}
 
copyReports();