From da6a525747a7bbb9ebfc474f3d654c46dd2e144e Mon Sep 17 00:00:00 2001 From: Mykola Grybyk Date: Thu, 8 Feb 2024 13:14:43 +0100 Subject: [PATCH] debug --- dist/index.js | 15 +++++++++------ src/cleanup.ts | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index 24eaa1f..84ccd29 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38771,6 +38771,7 @@ const cleanupOutdatedBranches = async (ghPagesBaseDir) => { } }; const cleanupOutdatedReports = async (ghPagesBaseDir, maxReports) => { + console.log(maxReports); try { const localBranches = (await promises_.readdir(ghPagesBaseDir, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name); // branches @@ -38784,13 +38785,15 @@ const cleanupOutdatedReports = async (ghPagesBaseDir, maxReports) => { .filter((d) => d.isDirectory()) .map((d) => d.name); // run per report - if (runs.length > maxReports) { + if (runs.length > 0) { runs.sort(); - while (runs.length > maxReports) { - await promises_.rm(external_path_.join(ghPagesBaseDir, localBranch, reportName, runs.shift()), { - recursive: true, - force: true, - }); + while (runs.length > 0) { + const pathToDelete = external_path_.join(ghPagesBaseDir, localBranch, reportName, runs.shift()); + console.log(pathToDelete); + // await fs.rm(path.join(ghPagesBaseDir, localBranch, reportName, runs.shift() as string), { + // recursive: true, + // force: true, + // }) } } } diff --git a/src/cleanup.ts b/src/cleanup.ts index 5c8766f..67f8458 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -25,6 +25,7 @@ export const cleanupOutdatedBranches = async (ghPagesBaseDir: string) => { } export const cleanupOutdatedReports = async (ghPagesBaseDir: string, maxReports: number) => { + console.log(maxReports) try { const localBranches = (await fs.readdir(ghPagesBaseDir, { withFileTypes: true })).filter((d) => d.isDirectory()).map((d) => d.name) @@ -41,13 +42,15 @@ export const cleanupOutdatedReports = async (ghPagesBaseDir: string, maxReports: .map((d) => d.name) // run per report - if (runs.length > maxReports) { + if (runs.length > 0) { runs.sort() - while (runs.length > maxReports) { - await fs.rm(path.join(ghPagesBaseDir, localBranch, reportName, runs.shift() as string), { - recursive: true, - force: true, - }) + while (runs.length > 0) { + const pathToDelete = path.join(ghPagesBaseDir, localBranch, reportName, runs.shift() as string) + console.log(pathToDelete) + // await fs.rm(path.join(ghPagesBaseDir, localBranch, reportName, runs.shift() as string), { + // recursive: true, + // force: true, + // }) } } }