Skip to content

Commit

Permalink
Allow redownloads on install
Browse files Browse the repository at this point in the history
  • Loading branch information
ta-Hirose committed Aug 16, 2022
1 parent c97b6a5 commit 6507db2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions dim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ await new Command()
"Specify the header. Can specify multiple times.",
{ collect: true },
)
.option(
"-F, --force",
"Force execution.",
)
.description(
"Install the data.\n" +
"Specify the url of data. If you dont't specify argument, install all data which is not installed dependency.",
Expand Down
11 changes: 9 additions & 2 deletions libs/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class InstallAction {
postProcesses?: string[];
name?: string;
headers?: string[];
force?: boolean;
},
url: string | undefined,
) {
Expand All @@ -184,8 +185,9 @@ export class InstallAction {
const targetContent = new DimFileAccessor().getContents().find((c) =>
c.name === options.name
);
if (targetContent !== undefined) {
if (targetContent !== undefined && options.force === undefined) {
console.log("The name already exists.");
console.log("Forced execution requires the -F option");
Deno.exit(1);
}
const result = await installFromURL(
Expand Down Expand Up @@ -235,7 +237,11 @@ export class InstallAction {
Colors.green(`Installed to ${fullPath}`),
);
} else {
const lockContentList = await installFromDimFile().catch((error) => {
let force = false;
if (options.force !== undefined) {
force = true;
}
const lockContentList = await installFromDimFile(force).catch((error) => {
console.error(
Colors.red("Failed to install."),
Colors.red(error.message),
Expand All @@ -250,6 +256,7 @@ export class InstallAction {
);
} else {
console.log("All contents have already been installed.");
console.log("Forced execution requires the -F option");
}
}
}
Expand Down

0 comments on commit 6507db2

Please sign in to comment.