Skip to content

Commit

Permalink
debug package list from github
Browse files Browse the repository at this point in the history
  • Loading branch information
jstaresincic committed Sep 7, 2022
1 parent 9a0530d commit 44a49f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
7 changes: 5 additions & 2 deletions delete-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ async function deletePackageVersions(
const toDelete = [];
for (const key in majorVersions) {
let vs = majorVersions[key];
info("All versions: ");
vs.map((v) => info("v: " + v));
vs = vs.reverse();
if (vs.length <= keepCnt) {
continue;
}
info("vs.length before slice: " + vs.length + " keepCnt: " + keepCnt);
vs = vs.slice(0, vs.length - keepCnt);
info("vs.length after slice: " + vs.length);
vs.forEach((v) => {
toDelete.push(v);
});
Expand All @@ -82,7 +86,6 @@ async function deletePackageVersions(
for (let i = 0; i < toDelete.length; i++) {
// on dryRun just add as deleted
if (dryRun) {
info("deletePackageVersion received dryRun as true");
deleted.push(toDelete[i]);
continue;
}
Expand Down Expand Up @@ -111,7 +114,7 @@ module.exports = async function (inputs) {
);
info("All packages list:");
packages = packages.filter((p) => {
info("p: " + p.name);
info(p.name);
return !p.name.startsWith("deleted_");
});

Expand Down
14 changes: 4 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ async function run() {
const inputs = {
owner: getInput("owner") || context.repo.owner,
repo: getInput("repo") || context.repo.repo,
keepCnt: getInput("keepCnt"),
keepCnt: Number(getInput("keepCnt")), // getInput converts ALL values to string!
dryRun: getInput("dryRun"),
token: getInput("token"),
};
info("Input values:");
Object.entries(inputs).map((v) => info(v[0] + ": " + v[1]));
if (inputs.dryRun === "false") inputs.dryRun = false;
if (inputs.dryRun === "false") inputs.dryRun = false; // getInput converts ALL values to string!
if (inputs.dryRun) {
info(
"How do I receive dryRun? Type: " +
typeof inputs.dryRun +
" Value: " +
inputs.dryRun
);
info(
"Dry run is NOT deleting packages, list below is what would be deleted, dryRun: " +
Number(inputs.dryRun)
Expand Down

0 comments on commit 44a49f2

Please sign in to comment.