Prefer native node fetch over node-fetch (#1970)

This commit is contained in:
Michael Telatynski 2024-10-31 11:16:36 +00:00 committed by GitHub
parent e66db793bf
commit 098609607b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 8 additions and 8 deletions

View File

@ -63,7 +63,6 @@
"electron-store": "^10.0.0",
"electron-window-state": "^5.0.3",
"minimist": "^1.2.6",
"node-fetch": "^2",
"png-to-ico": "^2.1.1",
"uuid": "^11.0.0"
},

View File

@ -5,7 +5,6 @@ import { createWriteStream, promises as fs } from "node:fs";
import * as childProcess from "node:child_process";
import * as tar from "tar";
import * as asar from "@electron/asar";
import fetch from "node-fetch";
import { promises as stream } from "node:stream";
import riotDesktopPackageJson from "../package.json";
@ -125,6 +124,8 @@ async function main(): Promise<number | undefined> {
});
fetch(PUB_KEY_URL)
.then((resp) => {
if (!resp.ok) throw new Error(`unexpected response ${resp.statusText}`);
if (!resp.body) throw new Error(`unexpected response has no body ${resp.statusText}`);
stream.pipeline(resp.body, gpgProc.stdin!).catch(reject);
})
.catch(reject);

View File

@ -2,12 +2,13 @@
"compilerOptions": {
"resolveJsonModule": true,
"moduleResolution": "node16",
"skipLibCheck": true,
"esModuleInterop": true,
"target": "es2022",
"module": "node16",
"sourceMap": false,
"strict": true,
"lib": ["es2020", "dom"]
"lib": ["es2020"]
},
"include": ["../src/@types", "./**/*.ts"]
}

View File

@ -31,8 +31,8 @@ async function safeCheckForUpdate(): Promise<void> {
// To avoid this we check manually whether an update is available and call the
// autoUpdater.checkForUpdates() when something new is there.
try {
const res = await global.fetch(feedUrl);
const { currentRelease } = await res.json();
const res = await fetch(feedUrl);
const { currentRelease } = (await res.json()) as { currentRelease: string };
const latestVersionDownloaded = latestUpdateDownloaded?.releaseName;
console.info(
`Latest version from release download: ${currentRelease} (current: ${app.getVersion()}, most recent downloaded ${latestVersionDownloaded}})`,

View File

@ -23,7 +23,6 @@ import {
} from "electron";
import url from "node:url";
import fs from "node:fs";
import fetch from "node-fetch";
import { pipeline } from "node:stream/promises";
import path from "node:path";

View File

@ -11,7 +11,7 @@
"rootDir": "./src",
"declaration": true,
"typeRoots": ["src/@types", "node_modules/@types"],
"lib": ["es2022", "dom"],
"lib": ["es2022"],
"types": ["node"],
"strict": true
},

View File

@ -5564,7 +5564,7 @@ node-api-version@^0.2.0:
dependencies:
semver "^7.3.5"
node-fetch@^2, node-fetch@^2.6.7:
node-fetch@^2.6.7:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==