Skip to content

Commit 0986096

Browse files
authored
Prefer native node fetch over node-fetch (#1970)
1 parent e66db79 commit 0986096

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"electron-store": "^10.0.0",
6464
"electron-window-state": "^5.0.3",
6565
"minimist": "^1.2.6",
66-
"node-fetch": "^2",
6766
"png-to-ico": "^2.1.1",
6867
"uuid": "^11.0.0"
6968
},

scripts/fetch-package.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createWriteStream, promises as fs } from "node:fs";
55
import * as childProcess from "node:child_process";
66
import * as tar from "tar";
77
import * as asar from "@electron/asar";
8-
import fetch from "node-fetch";
98
import { promises as stream } from "node:stream";
109

1110
import riotDesktopPackageJson from "../package.json";
@@ -125,6 +124,8 @@ async function main(): Promise<number | undefined> {
125124
});
126125
fetch(PUB_KEY_URL)
127126
.then((resp) => {
127+
if (!resp.ok) throw new Error(`unexpected response ${resp.statusText}`);
128+
if (!resp.body) throw new Error(`unexpected response has no body ${resp.statusText}`);
128129
stream.pipeline(resp.body, gpgProc.stdin!).catch(reject);
129130
})
130131
.catch(reject);

scripts/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"compilerOptions": {
33
"resolveJsonModule": true,
44
"moduleResolution": "node16",
5+
"skipLibCheck": true,
56
"esModuleInterop": true,
67
"target": "es2022",
78
"module": "node16",
89
"sourceMap": false,
910
"strict": true,
10-
"lib": ["es2020", "dom"]
11+
"lib": ["es2020"]
1112
},
1213
"include": ["../src/@types", "./**/*.ts"]
1314
}

src/updater.ts

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

src/webcontents-handler.ts

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
} from "electron";
2424
import url from "node:url";
2525
import fs from "node:fs";
26-
import fetch from "node-fetch";
2726
import { pipeline } from "node:stream/promises";
2827
import path from "node:path";
2928

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"rootDir": "./src",
1212
"declaration": true,
1313
"typeRoots": ["src/@types", "node_modules/@types"],
14-
"lib": ["es2022", "dom"],
14+
"lib": ["es2022"],
1515
"types": ["node"],
1616
"strict": true
1717
},

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -5564,7 +5564,7 @@ node-api-version@^0.2.0:
55645564
dependencies:
55655565
semver "^7.3.5"
55665566

5567-
node-fetch@^2, node-fetch@^2.6.7:
5567+
node-fetch@^2.6.7:
55685568
version "2.7.0"
55695569
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
55705570
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==

0 commit comments

Comments
 (0)