Skip to content

Commit

Permalink
create serial number dir under name option dir
Browse files Browse the repository at this point in the history
  • Loading branch information
JQinglong committed May 7, 2023
1 parent 899a35e commit 7b9cb5f
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions libs/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ export class InstallAction {
const html = await getResult.text();
const document = new DOMParser().parseFromString(html, "text/html");
const linklist = document.getElementsByTagName("a");
let idx = 0;
for (const link of linklist) {
const re = new RegExp(options.expression, "ig");
let href = new URL(
link.getAttribute("href"),
options.pageInstall
).toString();
if (re.test(href)) {
console.log(href, link.textContent);
idx += 1;
let dataName = "";
if (options.name !== undefined) {
dataName =
options.name + "/" + idx.toString() + "_" + link.textContent;
} else {
dataName = idx.toString() + "_" + link.textContent;
}
const fullPath = await installFromURL(
href,
link.textContent,
dataName,
options.postProcesses,
parsedHeaders
).catch((error) => {
Expand Down Expand Up @@ -93,11 +101,11 @@ export class InstallAction {
parsedHeaders,
).catch(
(error) => {
console.error(
Colors.red("Failed to install."),
console.error(
Colors.red("Failed to install."),
Colors.red(error.message),
);
Deno.exit(1);
);
Deno.exit(1);
},
);
console.log(
Expand Down Expand Up @@ -292,11 +300,11 @@ export class UpdateAction {
content.headers,
).catch(
(error) => {
console.error(
Colors.red("Failed to update."),
console.error(
Colors.red("Failed to update."),
Colors.red(error.message),
);
Deno.exit(1);
);
Deno.exit(1);
},
);
if (fullPath !== undefined) {
Expand Down

0 comments on commit 7b9cb5f

Please sign in to comment.