Skip to content

Commit 0352868

Browse files
committed
Require Node.js 12.20
1 parent 08b3cf7 commit 0352868

File tree

8 files changed

+42
-47
lines changed

8 files changed

+42
-47
lines changed

.github/funding.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 16
1314
- 14
1415
- 12
15-
- 10
16-
- 8
1716
steps:
1817
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
2019
with:
2120
node-version: ${{ matrix.node-version }}
2221
- run: npm install

api.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
22
/* eslint-env browser */
3+
const {isDeepStrictEqual} = require('util');
34
const puppeteer = require('puppeteer');
45
const Observable = require('zen-observable');
5-
const equals = require('deep-equal'); // TODO: Use `util.isDeepStrictEqual` when targeting Node.js 10
66
const delay = require('delay');
77

88
async function init(browser, page, observer, options) {
9-
let prevResult;
9+
let previousResult;
1010

1111
/* eslint-disable no-constant-condition, no-await-in-loop */
1212
while (true) {
@@ -24,7 +24,7 @@ async function init(browser, page, observer, options) {
2424
};
2525
});
2626

27-
if (result.downloadSpeed > 0 && !equals(result, prevResult)) {
27+
if (result.downloadSpeed > 0 && !isDeepStrictEqual(result, previousResult)) {
2828
observer.next(result);
2929
}
3030

@@ -34,7 +34,7 @@ async function init(browser, page, observer, options) {
3434
return;
3535
}
3636

37-
prevResult = result;
37+
previousResult = result;
3838

3939
await delay(100);
4040
}
@@ -49,6 +49,6 @@ module.exports = options => (
4949
const page = await browser.newPage();
5050
await page.goto('https://fast.com');
5151
await init(browser, page, observer, options);
52-
})().catch(observer.error.bind(observer));
52+
})().catch(observer.error.bind(observer)); // eslint-disable-line promise/prefer-await-to-then
5353
})
5454
);

cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const importJsx = require('import-jsx');
55
const React = require('react');
66
const {render} = require('ink');
77

8+
// Note to self: This cannot be ESM until https://github.com/vadimdemedes/import-jsx/issues/15 is fixed.
9+
810
const ui = importJsx('./ui');
911

1012
const cli = meow(`

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Test your download and upload speed using fast.com",
55
"license": "MIT",
66
"repository": "sindresorhus/fast-cli",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "[email protected]",
@@ -13,7 +14,7 @@
1314
"fast": "cli.js"
1415
},
1516
"engines": {
16-
"node": ">=8"
17+
"node": ">=12.20"
1718
},
1819
"scripts": {
1920
"test": "xo && ava"
@@ -43,23 +44,23 @@
4344
"mbps"
4445
],
4546
"dependencies": {
46-
"deep-equal": "^1.0.1",
47-
"delay": "^4.1.0",
47+
"delay": "^5.0.0",
4848
"import-jsx": "^4.0.0",
4949
"ink": "^3.0.8",
50-
"ink-spinner": "^4.0.1",
51-
"meow": "^5.0.0",
52-
"puppeteer": "^1.12.1",
53-
"react": "^17.0.1",
54-
"zen-observable": "^0.8.13"
50+
"ink-spinner": "^4.0.2",
51+
"meow": "^9.0.0",
52+
"puppeteer": "^9.1.1",
53+
"react": "^16.8.0",
54+
"zen-observable": "^0.8.15"
5555
},
5656
"devDependencies": {
57-
"ava": "^1.2.1",
58-
"eslint-config-xo-react": "^0.23.0",
59-
"eslint-plugin-react": "^7.21.5",
57+
"ava": "^2.4.0",
58+
"eslint-config-xo-react": "^0.25.0",
59+
"eslint-plugin-react": "^7.23.2",
6060
"eslint-plugin-react-hooks": "^4.2.0",
61-
"execa": "^1.0.0",
62-
"xo": "^0.24.0"
61+
"execa": "^5.0.0",
62+
"p-event": "^4.2.0",
63+
"xo": "^0.39.1"
6364
},
6465
"xo": {
6566
"extends": [

test.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import childProcess from 'child_process';
22
import execa from 'execa';
3+
import pEvent from 'p-event';
34
import test from 'ava';
45

5-
test.cb('default', t => {
6-
// TODO: Use `execa` here when the `spawn` API is done
7-
const cp = childProcess.spawn('./cli.js', {stdio: 'inherit'});
8-
9-
cp.on('error', t.fail);
10-
11-
cp.on('close', code => {
12-
t.is(code, 0);
13-
t.end();
14-
});
6+
test('default', async t => {
7+
const subprocess = childProcess.spawn('./cli.js', {stdio: 'inherit'});
8+
t.is(await pEvent(subprocess, 'close'), 0);
159
});
1610

1711
test('non-tty', async t => {
18-
t.regex(await execa.stdout('./cli.js'), /^\d+(?:\.\d+)? \w+$/i);
12+
const {stdout} = await execa('./cli.js');
13+
t.regex(stdout, /\d+(?:\.\d+)? \w+/i);
1914
});

ui.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use strict';
2-
const dns = require('dns');
2+
const {promises: dns} = require('dns');
33
const React = require('react');
44
const {useState, useEffect} = require('react');
55
const {Box, Text, Newline, useApp} = require('ink');
66
const Spinner = require('ink-spinner').default;
7-
8-
const api = require('./api');
7+
const api = require('./api.js');
98

109
const FixedSpacer = ({size}) => (
1110
<>{' '.repeat(size)}</>
@@ -82,8 +81,10 @@ const Fast = ({singleLine, upload}) => {
8281
const {exit} = useApp();
8382

8483
useEffect(() => {
85-
dns.lookup('fast.com', error => {
86-
if (error) {
84+
(async () => {
85+
try {
86+
await dns.lookup('fast.com');
87+
} catch (error) {
8788
setError(error.code === 'ENOTFOUND' ?
8889
'Please check your internet connection' :
8990
`Something happened ${JSON.stringify(error)}`
@@ -92,14 +93,15 @@ const Fast = ({singleLine, upload}) => {
9293
return;
9394
}
9495

96+
// eslint-disable-next-line unicorn/no-array-for-each
9597
api({measureUpload: upload}).forEach(result => {
9698
setData(result);
97-
}).catch(error2 => {
98-
setError(error2.message);
99+
}).catch(error_ => { // eslint-disable-line promise/prefer-await-to-then
100+
setError(error_.message);
99101
exit();
100102
});
101-
});
102-
}, []);
103+
})();
104+
}, [exit, upload]);
103105

104106
useEffect(() => {
105107
if (data.isDone || (!upload && data.uploadSpeed)) {
@@ -129,7 +131,7 @@ const Fast = ({singleLine, upload}) => {
129131
</>
130132
)}
131133
{isDone && <Text><FixedSpacer size={4}/></Text>}
132-
{Object.keys(data).length !== 0 && <Speed upload={upload} data={data}/>}
134+
{Object.keys(data).length > 0 && <Speed upload={upload} data={data}/>}
133135
</Box>
134136
<Spacer singleLine={singleLine}/>
135137
</>

0 commit comments

Comments
 (0)