tuiweather 0.3.2 → 0.3.7

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/README.md CHANGED
@@ -16,13 +16,15 @@ Keyboard-driven terminal weather app: Dark Sky-style rain nowcasting, hourly and
16
16
 
17
17
  ## Install
18
18
 
19
- Install globally with npm:
19
+ Requires Node.js to run: the package declares `engines.node >= 20`, and the command-line
20
+ paths (`--version`, `--help`, `--one-line`) work on any such Node; the interactive TUI
21
+ needs Node >= 26.4.0, enforced at runtime by the launcher. Install globally with npm:
20
22
 
21
23
  ```sh
22
24
  npm install --global tuiweather
23
25
  ```
24
26
 
25
- or with Bun:
27
+ or with the Bun package manager:
26
28
 
27
29
  ```sh
28
30
  bun install --global tuiweather
package/bin/tuiweather.js CHANGED
@@ -1,2 +1,39 @@
1
- #!/usr/bin/env bun
2
- import "../dist/index.js";
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const FFI_FLAGS = ["--experimental-ffi", "--disable-warning=ExperimentalWarning"];
6
+ const FFI_MIN_NODE = [26, 4, 0];
7
+
8
+ function nodeAtLeast(min) {
9
+ const parts = process.versions.node.split(".").map(Number);
10
+ for (let i = 0; i < min.length; i++) {
11
+ const have = parts[i] ?? 0;
12
+ if (have !== min[i]) return have > min[i];
13
+ }
14
+ return true;
15
+ }
16
+
17
+ const underBun = Boolean(process.versions.bun);
18
+ const hasFlags = FFI_FLAGS.every((flag) => process.execArgv.includes(flag));
19
+
20
+ if (underBun || hasFlags || !nodeAtLeast(FFI_MIN_NODE)) {
21
+ await import("../dist/index.js");
22
+ } else {
23
+ const script = fileURLToPath(new URL("../dist/index.js", import.meta.url));
24
+ const child = spawnSync(process.execPath, [...FFI_FLAGS, script, ...process.argv.slice(2)], {
25
+ stdio: "inherit",
26
+ });
27
+ if (child.error) {
28
+ console.error(child.error.message);
29
+ process.exitCode = 1;
30
+ } else if (child.signal) {
31
+ try {
32
+ process.kill(process.pid, child.signal);
33
+ } catch {
34
+ process.exitCode = child.status ?? 1;
35
+ }
36
+ } else {
37
+ process.exitCode = child.status ?? 1;
38
+ }
39
+ }