netspeed-test-cli 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.js +12 -33
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -126,34 +126,6 @@ function printResult(type, value, icon) {
126
126
  console.log(chalk.white(' └' + '─'.repeat(20) + '┘'));
127
127
  }
128
128
 
129
- async function main() {
130
- printHeader();
131
-
132
- console.log(chalk.gray(' Starting speed test...\n'));
133
-
134
- const pingStop = showSpinner('Measuring ping...');
135
- const ping = await pingTest();
136
- pingStop();
137
- clearLine();
138
- printResult('ping', `${ping} ms`, '⚡');
139
-
140
- const downloadStop = showSpinner('Testing download speed...');
141
- const download = await downloadTest();
142
- downloadStop();
143
- clearLine();
144
- printResult('download', `${download} Mbps`, '📥');
145
-
146
- const uploadStop = showSpinner('Testing upload speed...');
147
- const upload = (parseFloat(download) * 0.3).toFixed(2);
148
- uploadStop();
149
- clearLine();
150
- printResult('upload', `${upload} Mbps`, '📤');
151
-
152
- console.log();
153
- console.log(chalk.gray(' ' + '─'.repeat(40)));
154
- console.log();
155
- }
156
-
157
129
  async function runSpeedTest() {
158
130
  console.log(chalk.gray(' Starting speed test...\n'));
159
131
 
@@ -250,9 +222,8 @@ async function main() {
250
222
  break;
251
223
  case '2':
252
224
  showVersion();
253
- const readline = await import('readline');
254
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
255
- rl.question('', () => { rl.close(); main(); });
225
+ await waitForEnter();
226
+ await main();
256
227
  break;
257
228
  case '3':
258
229
  await updatePackage();
@@ -262,9 +233,17 @@ async function main() {
262
233
  process.exit(0);
263
234
  default:
264
235
  console.log(chalk.red(' Invalid choice. Press ENTER to try again.'));
265
- const rl = (await import('readline')).createInterface({ input: process.stdin, output: process.stdout });
266
- rl.question('', () => { rl.close(); main(); });
236
+ await waitForEnter();
237
+ await main();
267
238
  }
268
239
  }
269
240
 
241
+ async function waitForEnter() {
242
+ const readline = await import('readline');
243
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
244
+ return new Promise((resolve) => {
245
+ rl.question('', () => { rl.close(); resolve(); });
246
+ });
247
+ }
248
+
270
249
  main().catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netspeed-test-cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Internet speed test CLI tool",
5
5
  "bin": {
6
6
  "netspeed": "bin/cli.js"