@rg-dev/stdlib 1.0.12 → 1.0.14

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.
@@ -6077,12 +6077,12 @@ async function getFetch() {
6077
6077
  }
6078
6078
  return (await Promise.resolve().then(() => (init_src(), src_exports))).default;
6079
6079
  }
6080
- function downloadFile(url, destination) {
6080
+ function downloadFile(url, destination, headers) {
6081
6081
  return new Promise(
6082
6082
  async (resolve, reject) => {
6083
6083
  try {
6084
6084
  const fetcher = await getFetch();
6085
- const response = await fetcher(url);
6085
+ const response = await fetcher(url, { headers: { ...headers || {} } });
6086
6086
  if (!response.ok)
6087
6087
  throw new Error("Error downloading file");
6088
6088
  const dest = fs2.createWriteStream(destination);
@@ -6093,8 +6093,12 @@ function downloadFile(url, destination) {
6093
6093
  import_stream.Readable.fromWeb(body).pipe(dest);
6094
6094
  }
6095
6095
  dest.on("finish", () => resolve(destination));
6096
- dest.on("error", reject);
6096
+ dest.on("error", (e2) => {
6097
+ console.error("error downloading", url);
6098
+ reject(e2);
6099
+ });
6097
6100
  } catch (e2) {
6101
+ console.error("error downloading", url);
6098
6102
  reject(e2);
6099
6103
  }
6100
6104
  }
@@ -1,3 +1,3 @@
1
- declare function downloadFile(url: string, destination: string): Promise<string>;
1
+ declare function downloadFile(url: string, destination: string, headers?: Record<string, any>): Promise<string>;
2
2
 
3
3
  export { downloadFile };
@@ -1,3 +1,3 @@
1
- declare function downloadFile(url: string, destination: string): Promise<string>;
1
+ declare function downloadFile(url: string, destination: string, headers?: Record<string, any>): Promise<string>;
2
2
 
3
3
  export { downloadFile };
@@ -6078,12 +6078,12 @@ async function getFetch() {
6078
6078
  }
6079
6079
  return (await Promise.resolve().then(() => (init_src(), src_exports))).default;
6080
6080
  }
6081
- function downloadFile(url, destination) {
6081
+ function downloadFile(url, destination, headers) {
6082
6082
  return new Promise(
6083
6083
  async (resolve, reject) => {
6084
6084
  try {
6085
6085
  const fetcher = await getFetch();
6086
- const response = await fetcher(url);
6086
+ const response = await fetcher(url, { headers: { ...headers || {} } });
6087
6087
  if (!response.ok)
6088
6088
  throw new Error("Error downloading file");
6089
6089
  const dest = fs2.createWriteStream(destination);
@@ -6094,8 +6094,12 @@ function downloadFile(url, destination) {
6094
6094
  Readable.fromWeb(body).pipe(dest);
6095
6095
  }
6096
6096
  dest.on("finish", () => resolve(destination));
6097
- dest.on("error", reject);
6097
+ dest.on("error", (e2) => {
6098
+ console.error("error downloading", url);
6099
+ reject(e2);
6100
+ });
6098
6101
  } catch (e2) {
6102
+ console.error("error downloading", url);
6099
6103
  reject(e2);
6100
6104
  }
6101
6105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",