Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrybyk committed Feb 8, 2024
1 parent 05ba0a0 commit da6a525
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
// })
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
// })
}
}
}
Expand Down

0 comments on commit da6a525

Please sign in to comment.