@rg-dev/stdlib 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/node-download.cjs +14 -3
- package/lib/node-download.d.cts +1 -1
- package/lib/node-download.d.ts +1 -1
- package/lib/node-download.js +14 -3
- package/package.json +1 -1
package/lib/node-download.cjs
CHANGED
|
@@ -6083,8 +6083,15 @@ function downloadFile(url, destination, headers) {
|
|
|
6083
6083
|
try {
|
|
6084
6084
|
const fetcher = await getFetch();
|
|
6085
6085
|
const response = await fetcher(url, { headers: { ...headers || {} } });
|
|
6086
|
-
if (!response.ok)
|
|
6087
|
-
|
|
6086
|
+
if (!response.ok) {
|
|
6087
|
+
try {
|
|
6088
|
+
const error = await (response == null ? void 0 : response.text());
|
|
6089
|
+
if (error)
|
|
6090
|
+
throw new Error(error);
|
|
6091
|
+
} catch (e2) {
|
|
6092
|
+
}
|
|
6093
|
+
throw new Error("Error downloading file ");
|
|
6094
|
+
}
|
|
6088
6095
|
const dest = fs2.createWriteStream(destination);
|
|
6089
6096
|
const body = response.body;
|
|
6090
6097
|
if (body["pipe"]) {
|
|
@@ -6093,8 +6100,12 @@ function downloadFile(url, destination, headers) {
|
|
|
6093
6100
|
import_stream.Readable.fromWeb(body).pipe(dest);
|
|
6094
6101
|
}
|
|
6095
6102
|
dest.on("finish", () => resolve(destination));
|
|
6096
|
-
dest.on("error",
|
|
6103
|
+
dest.on("error", (e2) => {
|
|
6104
|
+
console.error("error downloading", url);
|
|
6105
|
+
reject(e2);
|
|
6106
|
+
});
|
|
6097
6107
|
} catch (e2) {
|
|
6108
|
+
console.error("error downloading", url);
|
|
6098
6109
|
reject(e2);
|
|
6099
6110
|
}
|
|
6100
6111
|
}
|
package/lib/node-download.d.cts
CHANGED
package/lib/node-download.d.ts
CHANGED
package/lib/node-download.js
CHANGED
|
@@ -6084,8 +6084,15 @@ function downloadFile(url, destination, headers) {
|
|
|
6084
6084
|
try {
|
|
6085
6085
|
const fetcher = await getFetch();
|
|
6086
6086
|
const response = await fetcher(url, { headers: { ...headers || {} } });
|
|
6087
|
-
if (!response.ok)
|
|
6088
|
-
|
|
6087
|
+
if (!response.ok) {
|
|
6088
|
+
try {
|
|
6089
|
+
const error = await (response == null ? void 0 : response.text());
|
|
6090
|
+
if (error)
|
|
6091
|
+
throw new Error(error);
|
|
6092
|
+
} catch (e2) {
|
|
6093
|
+
}
|
|
6094
|
+
throw new Error("Error downloading file ");
|
|
6095
|
+
}
|
|
6089
6096
|
const dest = fs2.createWriteStream(destination);
|
|
6090
6097
|
const body = response.body;
|
|
6091
6098
|
if (body["pipe"]) {
|
|
@@ -6094,8 +6101,12 @@ function downloadFile(url, destination, headers) {
|
|
|
6094
6101
|
Readable.fromWeb(body).pipe(dest);
|
|
6095
6102
|
}
|
|
6096
6103
|
dest.on("finish", () => resolve(destination));
|
|
6097
|
-
dest.on("error",
|
|
6104
|
+
dest.on("error", (e2) => {
|
|
6105
|
+
console.error("error downloading", url);
|
|
6106
|
+
reject(e2);
|
|
6107
|
+
});
|
|
6098
6108
|
} catch (e2) {
|
|
6109
|
+
console.error("error downloading", url);
|
|
6099
6110
|
reject(e2);
|
|
6100
6111
|
}
|
|
6101
6112
|
}
|