about-system 0.0.14 → 0.0.15

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "about-system",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "A Node.js script to display key system information with emojis. Cross-platform support for Windows, macOS, and Linux with customizable output and caching.",
5
5
  "main": "src/about-system.js",
6
6
  "bin": {
@@ -7,9 +7,7 @@ import https from 'https';
7
7
  import { fileURLToPath } from 'url';
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url);
10
- import { fileURLToPath } from 'url';
11
10
 
12
- const __filename = fileURLToPath(import.meta.url);
13
11
 
14
12
  // Cache configuration
15
13
  const CACHE_FILE = path.join(os.tmpdir(), 'systeminfo-cache.json');
@@ -1,51 +0,0 @@
1
- import ora from 'ora';
2
- import { spawn, execSync } from 'child_process';
3
-
4
-
5
- /**
6
- * Tests the download speed in MB/s using Cloudflare's speed test.
7
- * Optionally displays a spinner message during the test.
8
- * Their official package is @cloudflare/speedtest and it shows errors and too much output.
9
- * This script uses a process to hide the errors and give speed in MB/s via CLI or import.
10
- * @param {boolean} [showMessage=true] - Whether to show explanation message while testing.
11
- * @returns {Promise<string>} The measured download speed in MB/s as a string (e.g., "12.3").
12
- *
13
- * @example
14
- * import { testDownloadSpeed } from './test-speed-cloudflare.js';
15
- * const downloadSpeed = await testDownloadSpeed(false);
16
- * console.log(downloadSpeed); // e.g., "12.3"
17
- */
18
- export async function testDownloadSpeed(showMessage = true) {
19
- var spinner;
20
- if (showMessage)
21
- spinner = ora('Testing download speed in MB/s using Cloudflare, runs for 1 minute').start();
22
-
23
- // globally install @cloudflare/speedtest
24
- await execSync('npm i -g @cloudflare/speedtest');
25
-
26
- const result = await new Promise((resolve) => {
27
- const child = spawn('node', [
28
- '-e',
29
- "import SpeedTest from '@cloudflare/speedtest'; new SpeedTest({iterations: 1}).onFinish = r => console.log((r.getDownloadBandwidth() / 8388608).toFixed(1))"
30
- ]);
31
-
32
- let output = '';
33
- child.stdout.on('data', (data) => {
34
- output += data.toString();
35
- });
36
- // Extract last number from output
37
- child.on('close', () => {
38
- resolve(output.trim().split('\n').pop().match(/(\d+(\.\d+)?)/)?.[0]);
39
- });
40
-
41
- });
42
-
43
- if (showMessage) spinner.succeed(result + ' MB/s');
44
- return result;
45
- }
46
-
47
- // try{
48
- // run if file is executed directly
49
- // if (process?.env.npm_lifecycle_event?.length > 0 || import.meta.url === `file://${process.argv[1]}` || import.meta.url === process.argv[1] || import.meta.url === `file://${process.cwd()}/${process.argv[1]}`)
50
- testDownloadSpeed();
51
- // } catch { }