Skip to content

Commit 28ed233

Browse files
committed
a workaround for node-fetch using esm
1 parent 05e6de2 commit 28ed233

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/utils/downloadFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* API for downloading information from web
33
*/
44
import { logger } from "./logger";
5-
import fetch from "node-fetch";
5+
import { fetch } from "./fetch";
66

77
export async function downloadFromMultiSources(urls: string[]): Promise<string | undefined> {
88
for (const url of urls) {

src/utils/fetch.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
// @ts-check
3+
4+
export const fetch =
5+
process.platform
6+
? eval("(...args) => import('node-fetch').then(({default: fetch}) => fetch(...args))")
7+
: window.fetch;

0 commit comments

Comments
 (0)