@evandu/super-pi 0.1.198 → 0.1.199

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.
@@ -0,0 +1 @@
1
+ export function npmInstallPrefix(rootDir: string, platform?: string): string | undefined;
@@ -0,0 +1,10 @@
1
+ /** Infer npm's global prefix from this package's installation root, not its node_modules parent. */
2
+ export function npmInstallPrefix(rootDir, platform = process.platform) {
3
+ const match = rootDir.match(/^(.*)[\\/]node_modules[\\/]@evandu[\\/]super-pi[\\/]?$/i);
4
+ if (!match) return undefined;
5
+ const parent = match[1];
6
+ // Unix global packages live in <prefix>/lib/node_modules; Windows omits lib.
7
+ // Passing the Unix lib directory as --prefix would install into lib/lib/node_modules.
8
+ if (platform !== "win32" && /[\\/]lib$/.test(parent)) return parent.slice(0, -4) || "/";
9
+ return parent;
10
+ }
package/bin/super-pi.js CHANGED
@@ -6,12 +6,13 @@ import { homedir } from "node:os";
6
6
  import { dirname, join, resolve } from "node:path";
7
7
  import { promisify } from "node:util";
8
8
  import { pathToFileURL } from "node:url";
9
+ import { npmInstallPrefix } from "./npm-prefix.js";
9
10
 
10
11
  const execFileAsync = promisify(execFile);
11
12
  const root = resolve(import.meta.dirname, "..");
12
13
  const entry = resolve(root, "dist/server/index.js");
13
- const prefix = root.match(/^(.*)[\\/]node_modules[\\/]/i)?.[1];
14
14
  const platform = process.env.SUPER_PI_AUTOSTART_PLATFORM ?? process.platform;
15
+ const prefix = npmInstallPrefix(root, platform);
15
16
  const home = process.env.SUPER_PI_AUTOSTART_HOME ?? homedir();
16
17
 
17
18
  /**
@@ -40,5 +40,5 @@
40
40
  "src/client/types.ts": "0d32fd568f188507ce2b48266f44fa20da1bcf436090893b1ff0c164ed0f3132",
41
41
  "src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
42
42
  },
43
- "recordedAt": "2026-11-12T14:53:27.683Z"
43
+ "recordedAt": "2026-11-12T15:12:54.897Z"
44
44
  }
@@ -33,7 +33,7 @@ export declare function shellArgs(args: string[]): string[];
33
33
  * The fetch options are there because the tarball is ~32 MB: npm's default
34
34
  * 5 minute timeout fails on a slow line and the update looks broken.
35
35
  */
36
- export declare function packageUpdateArgs(rootDir: string, version?: string): {
36
+ export declare function packageUpdateArgs(rootDir: string, version?: string, platform?: NodeJS.Platform): {
37
37
  args: string[];
38
38
  prefix?: string;
39
39
  };
@@ -1,4 +1,4 @@
1
- import { sep } from "node:path";
1
+ import { npmInstallPrefix } from "../../bin/npm-prefix.js";
2
2
  /**
3
3
  * Quote an argument for a shell on Windows.
4
4
  *
@@ -38,16 +38,13 @@ export function shellArgs(args) {
38
38
  * The fetch options are there because the tarball is ~32 MB: npm's default
39
39
  * 5 minute timeout fails on a slow line and the update looks broken.
40
40
  */
41
- export function packageUpdateArgs(rootDir, version) {
42
- const marker = `${sep}node_modules${sep}`;
43
- const lower = rootDir.toLowerCase();
44
- const index = lower.lastIndexOf(marker);
41
+ export function packageUpdateArgs(rootDir, version, platform = process.platform) {
42
+ const prefix = npmInstallPrefix(rootDir, platform);
45
43
  // THE VERSION THE USER CONFIRMED. The check reads the registry directly while npm resolves
46
44
  // "latest" from its own cache, so the two can disagree: the dialog promises vX and the
47
45
  // install silently lands on vY. Pinning the version the dialog showed removes that gap.
48
46
  const target = version ? `@evandu/super-pi@${version}` : "@evandu/super-pi";
49
- if (index >= 0) {
50
- const prefix = rootDir.slice(0, index);
47
+ if (prefix !== undefined) {
51
48
  return { prefix, args: ["install", "-g", "--prefix", prefix, "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", target] };
52
49
  }
53
50
  return { args: ["install", "-g", "--fetch-timeout=900000", "--fetch-retries=8", "--fetch-retry-maxtimeout=120000", target] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.198",
3
+ "version": "0.1.199",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",