Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: punycode error for non CI #2587

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/quicktype-core/src/input/io/NodeIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as fs from "fs";

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

Expand All @@ -11,10 +10,9 @@ import { messageError, panic } from "../../index";

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

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

interface HttpHeaders {
[key: string]: string;
Expand Down
Loading