Skip to content

Commit c7837e6

Browse files
avalleteavallete
andauthored
fix: punycode error for non CI (#2587)
* fix: punycode error for non CI * chore: remove build artifacts * fix: import add comment --------- Co-authored-by: avallete <andrew@snaplet.dev>
1 parent 37320e7 commit c7837e6

File tree

1 file changed

+3
-5
lines changed
  • packages/quicktype-core/src/input/io

1 file changed

+3
-5
lines changed

packages/quicktype-core/src/input/io/NodeIO.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as fs from "fs";
22

33
import { defined, exceptionToString } from "@glideapps/ts-necessities";
44
import { isNode } from "browser-or-node";
5-
import _fetch from "cross-fetch";
65
import isURL from "is-url";
76
import { type Readable } from "readable-stream";
87

@@ -11,10 +10,9 @@ import { panic } from "../../support/Support";
1110

1211
import { getStream } from "./get-stream";
1312

14-
// Only use cross-fetch in CI
15-
// FIXME: type global
16-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17-
const fetch = process.env.CI ? _fetch : (global as any).fetch ?? _fetch;
13+
// We need to use cross-fetch in CI or if fetch is not available in the global scope
14+
// We use a dynamic import to avoid punycode deprecated dependency warning on node > 20
15+
const fetch = process.env.CI ? require("cross-fetch").default : (global as any).fetch ?? require("cross-fetch").default;
1816

1917
interface HttpHeaders {
2018
[key: string]: string;

0 commit comments

Comments
 (0)