Skip to content

Commit a8bb6f1

Browse files
authored
fix!: upgrade got to 11.8.5 (#225)
BREAKING CHANGE: minimum Node.js version is >= 12
1 parent 5c81f9a commit a8bb6f1

File tree

4 files changed

+187
-128
lines changed

4 files changed

+187
-128
lines changed

.circleci/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ version: 2.1
2121
orbs:
2222
win: circleci/[email protected]
2323
jobs:
24-
test-linux-8:
24+
test-linux-12:
2525
docker:
26-
- image: circleci/node:8
26+
- image: circleci/node:12
2727
<<: *steps-test
28-
test-linux-10:
28+
test-linux-14:
2929
docker:
30-
- image: circleci/node:10
30+
- image: circleci/node:14
3131
<<: *steps-test
3232
test-mac:
3333
macos:
@@ -52,14 +52,14 @@ workflows:
5252
test_and_release:
5353
# Run the test jobs first, then the release only when all the test jobs are successful
5454
jobs:
55-
- test-linux-8
56-
- test-linux-10
55+
- test-linux-12
56+
- test-linux-14
5757
- test-mac
5858
- test-windows
5959
- release:
6060
requires:
61-
- test-linux-8
62-
- test-linux-10
61+
- test-linux-12
62+
- test-linux-14
6363
- test-mac
6464
- test-windows
6565
filters:

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"README.md"
2424
],
2525
"engines": {
26-
"node": ">=8.6"
26+
"node": ">=12"
2727
},
2828
"dependencies": {
2929
"debug": "^4.1.1",
3030
"env-paths": "^2.2.0",
3131
"fs-extra": "^8.1.0",
32-
"got": "^9.6.0",
32+
"got": "^11.8.5",
3333
"progress": "^2.0.3",
3434
"semver": "^6.2.0",
3535
"sumchecker": "^3.0.1"
@@ -38,9 +38,8 @@
3838
"@continuous-auth/semantic-release-npm": "^2.0.0",
3939
"@types/debug": "^4.1.4",
4040
"@types/fs-extra": "^8.0.0",
41-
"@types/got": "^9.4.4",
4241
"@types/jest": "^24.0.13",
43-
"@types/node": "^12.0.2",
42+
"@types/node": "^12.20.55",
4443
"@types/progress": "^2.0.3",
4544
"@types/semver": "^6.2.0",
4645
"@typescript-eslint/eslint-plugin": "^2.34.0",

src/GotDownloader.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra';
2-
import * as got from 'got';
2+
import got, { HTTPError, Progress as GotProgress, Options as GotOptions } from 'got';
33
import * as path from 'path';
44
import * as ProgressBar from 'progress';
55

@@ -10,11 +10,11 @@ const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
1010
/**
1111
* See [`got#options`](https://github.com/sindresorhus/got#options) for possible keys/values.
1212
*/
13-
export type GotDownloaderOptions = got.GotOptions<string | null> & {
13+
export type GotDownloaderOptions = (GotOptions & { isStream?: true }) & {
1414
/**
1515
* if defined, triggers every time `got`'s `downloadProgress` event callback is triggered.
1616
*/
17-
getProgressCallback?: (progress: got.Progress) => Promise<void>;
17+
getProgressCallback?: (progress: GotProgress) => Promise<void>;
1818
/**
1919
* if `true`, disables the console progress bar (setting the `ELECTRON_GET_NO_PROGRESS`
2020
* environment variable to a non-empty value also does this).
@@ -56,7 +56,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
5656
}
5757
}, PROGRESS_BAR_DELAY_IN_SECONDS * 1000);
5858
}
59-
await new Promise((resolve, reject) => {
59+
await new Promise<void>((resolve, reject) => {
6060
const downloadStream = got.stream(url, gotOptions);
6161
downloadStream.on('downloadProgress', async progress => {
6262
progressPercent = progress.percent;
@@ -68,8 +68,8 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
6868
}
6969
});
7070
downloadStream.on('error', error => {
71-
if (error.name === 'HTTPError' && error.statusCode === 404) {
72-
error.message += ` for ${error.url}`;
71+
if (error instanceof HTTPError && error.response.statusCode === 404) {
72+
error.message += ` for ${error.response.url}`;
7373
}
7474
if (writeStream.destroy) {
7575
writeStream.destroy(error);

0 commit comments

Comments
 (0)