Skip to content

Commit

Permalink
modify the output from verify command
Browse files Browse the repository at this point in the history
  • Loading branch information
To-Ki-O committed Apr 11, 2023
1 parent 8d406bd commit 52e07ec
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions libs/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,32 @@ export class SearchAction {
export class VerifyAction {
async execute() {
const targetLockContents = new DimLockFileAccessor().getContents();
let result = true;

let count = 0;
for (const targetLockContent of targetLockContents) {
const consoleAnimation = new ConsoleAnimation(
["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
`${targetLockContent.name}: `,
);
consoleAnimation.start(100);
await ky.get(targetLockContent.url, targetLockContent.headers)
.then((response) => response.arrayBuffer())
.then((arrayBuffer) => {
const integrity = new Sha1().update(arrayBuffer).toString();
if (integrity !== targetLockContent.integrity) {
result = false;
if (integrity === targetLockContent.integrity) {
console.log(
Colors.green("latest"),
);
count += 1;
} else {
console.log(
Colors.red(`${targetLockContent.name}: verification failed`),
Colors.red(`outdated`),
);
console.log(` you can use update command "dim update ${targetLockContent.name}"`);
}
});
consoleAnimation.stop();
}
if (result) {
console.log(
Colors.green(`verification success`),
);
}
console.log(`All verification: done (${count}/${targetLockContents.length} is latest)`);
}
}

Expand Down

0 comments on commit 52e07ec

Please sign in to comment.