summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSindre Sorhus <sindresorhus@gmail.com>2019-02-25 14:47:09 +0700
committerSindre Sorhus <sindresorhus@gmail.com>2019-02-25 15:07:22 +0700
commit63fae5138f4e9e56bc55543c67bbae5fb6d21bb0 (patch)
tree240b11c1c88de380b7a83ce3abd5961f6a8de6ed
parent7b22d0219732711fd8764e55190c5f69790b5f82 (diff)
Meta tweaks and update dependencies
-rw-r--r--.gitattributes3
-rw-r--r--.travis.yml1
-rwxr-xr-xcli.js27
-rw-r--r--package.json12
-rw-r--r--readme.md9
-rw-r--r--screenshot.gifbin145844 -> 144706 bytes
-rw-r--r--test.js22
7 files changed, 38 insertions, 36 deletions
diff --git a/.gitattributes b/.gitattributes
index 391f0a4..6313b56 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1 @@
-* text=auto
-*.js text eol=lf
+* text=auto eol=lf
diff --git a/.travis.yml b/.travis.yml
index b3be97a..f3fa8cd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
language: node_js
node_js:
+ - '10'
- '8'
diff --git a/cli.js b/cli.js
index 3655d7e..b94fa97 100755
--- a/cli.js
+++ b/cli.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
'use strict';
-const url = require('url');
+const {URL} = require('url');
const meow = require('meow');
const speedtest = require('speedtest-net');
const updateNotifier = require('update-notifier');
@@ -48,7 +48,7 @@ const spinner = new Ora();
const unit = cli.flags.bytes ? 'MBps' : 'Mbps';
const multiplier = cli.flags.bytes ? 1 / 8 : 1;
-const getSpinner = x => state === x ? chalk.gray.dim(spinner.frame()) : ' ';
+const getSpinnerFromState = inputState => inputState === state ? chalk.gray.dim(spinner.frame()) : ' ';
const logError = error => {
if (cli.flags.json) {
@@ -65,9 +65,9 @@ function render() {
}
let output = `
- Ping ${getSpinner('ping')}${stats.ping}
- Download ${getSpinner('download')}${stats.download}
- Upload ${getSpinner('upload')}${stats.upload}`;
+ Ping ${getSpinnerFromState('ping')}${stats.ping}
+ Download ${getSpinnerFromState('download')}${stats.download}
+ Upload ${getSpinnerFromState('upload')}${stats.upload}`;
if (cli.flags.verbose) {
output += [
@@ -81,17 +81,16 @@ function render() {
logUpdate(output);
}
-function setState(s) {
- state = s;
+function setState(newState) {
+ state = newState;
- if (s && s.length > 0) {
- stats[s] = chalk.yellow(`0 ${chalk.dim(unit)}`);
+ if (newState && newState.length > 0) {
+ stats[newState] = chalk.yellow(`0 ${chalk.dim(unit)}`);
}
}
function map(server) {
- /* eslint-disable prefer-destructuring */
- server.host = url.parse(server.url).host;
+ server.host = new URL(server.url).host;
server.location = server.name;
server.distance = server.dist;
return server;
@@ -158,11 +157,11 @@ st.on('done', () => {
process.exit();
});
-st.on('error', err => {
- if (err.code === 'ENOTFOUND') {
+st.on('error', error => {
+ if (error.code === 'ENOTFOUND') {
logError('Please check your internet connection');
} else {
- logError(err);
+ logError(error);
}
process.exit(1);
diff --git a/package.json b/package.json
index f05c3a6..167bbbf 100644
--- a/package.json
+++ b/package.json
@@ -38,15 +38,15 @@
"chalk": "^2.3.0",
"log-symbols": "^2.2.0",
"log-update": "^2.3.0",
- "meow": "^4.0.0",
- "ora": "^1.4.0",
- "round-to": "^2.0.0",
+ "meow": "^5.0.0",
+ "ora": "^3.1.0",
+ "round-to": "^3.0.0",
"speedtest-net": "^1.2.4",
"update-notifier": "^2.3.0"
},
"devDependencies": {
- "ava": "*",
- "execa": "^0.9.0",
- "xo": "*"
+ "ava": "^1.2.1",
+ "execa": "^1.0.0",
+ "xo": "^0.24.0"
}
}
diff --git a/readme.md b/readme.md
index eb45821..2dda0a5 100644
--- a/readme.md
+++ b/readme.md
@@ -1,8 +1,6 @@
# speed-test [![Build Status](https://travis-ci.org/sindresorhus/speed-test.svg?branch=master)](https://travis-ci.org/sindresorhus/speed-test)
-> Test your internet connection speed and ping using [speedtest.net](http://www.speedtest.net) from the CLI
-
-**Discuss it on [Product Hunt](https://www.producthunt.com/posts/speed-test-cli)**
+> Test your internet connection speed and ping using [speedtest.net](https://www.speedtest.net) from the CLI
<img src="screenshot.gif" width="404">
@@ -31,6 +29,11 @@ $ speed-test --help
```
+## Links
+
+- [Product Hunt post](https://www.producthunt.com/posts/speed-test-cli)
+
+
## Related
- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download speed using fast.com
diff --git a/screenshot.gif b/screenshot.gif
index 09664f5..79c67c2 100644
--- a/screenshot.gif
+++ b/screenshot.gif
Binary files differ
diff --git a/test.js b/test.js
index 328ddde..82ad9be 100644
--- a/test.js
+++ b/test.js
@@ -5,7 +5,7 @@ import execa from 'execa';
test.cb('main', t => {
const cp = childProcess.spawn('./cli.js', {stdio: 'inherit'});
- cp.on('error', t.ifError);
+ cp.on('error', t.fail);
cp.on('close', code => {
t.is(code, 0);
@@ -15,18 +15,18 @@ test.cb('main', t => {
test('--json', async t => {
const {stdout} = await execa('./cli.js', ['--json']);
- const x = JSON.parse(stdout);
- t.truthy(x.ping);
- t.truthy(x.upload);
- t.truthy(x.download);
- t.falsy(x.data);
+ const parsed = JSON.parse(stdout);
+ t.truthy(parsed.ping);
+ t.truthy(parsed.upload);
+ t.truthy(parsed.download);
+ t.falsy(parsed.data);
});
test('--verbose --json', async t => {
const {stdout} = await execa('./cli.js', ['--verbose', '--json']);
- const x = JSON.parse(stdout);
- t.truthy(x.ping);
- t.truthy(x.upload);
- t.truthy(x.download);
- t.truthy(x.data);
+ const parsed = JSON.parse(stdout);
+ t.truthy(parsed.ping);
+ t.truthy(parsed.upload);
+ t.truthy(parsed.download);
+ t.truthy(parsed.data);
});