feat: update wget.ts
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
// - https://jsr.io/@chiba/wget/1.0.0/mod.ts
|
||||
|
||||
import { parseArgs } from "jsr:@std/cli/parse-args";
|
||||
import * as fs from "jsr:@std/fs@^1.0.0";
|
||||
import {
|
||||
clearLastLine,
|
||||
formatHumanTime,
|
||||
@@ -17,8 +16,14 @@ import {
|
||||
function getOutputFilename(filename: string): string {
|
||||
const original = filename;
|
||||
for (let i = 1; i < Number.MAX_SAFE_INTEGER; i++) {
|
||||
if (!fs.existsSync(filename)) {
|
||||
break;
|
||||
try {
|
||||
Deno.statSync(filename);
|
||||
// deno-lint-ignore no-explicit-any
|
||||
} catch (e: any) {
|
||||
if (e && e.name === "NotFound") {
|
||||
break;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
filename = `${original}.${i}`;
|
||||
}
|
||||
@@ -72,7 +77,7 @@ const outputFilename = flags.output || getOutputFilenameFromUrl(url);
|
||||
const startTime = new Date().getTime();
|
||||
let totalLength: number = -2;
|
||||
|
||||
console.log("Start download file:", url, " --> ", outputFilename);
|
||||
console.log(`Start download file: ${url} --> ${outputFilename}`);
|
||||
|
||||
const stateFileInterVal = setInterval(async () => {
|
||||
const costTime = new Date().getTime() - startTime;
|
||||
@@ -99,7 +104,7 @@ const outputFileWritable = Deno.createSync(outputFilename).writable;
|
||||
let init = undefined;
|
||||
const proxy = flags.proxy || getEnvironmentProxy();
|
||||
if (proxy) {
|
||||
console.log("Using proxy: ", proxy);
|
||||
console.log(`Using proxy: ${proxy}`);
|
||||
init = {
|
||||
client: Deno.createHttpClient({
|
||||
proxy: {
|
||||
|
||||
Reference in New Issue
Block a user