@oh-my-pi/pi-utils 16.2.4 → 16.2.6
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/CHANGELOG.md +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/path.d.ts +2 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/path.ts +28 -0
- package/src/worker-host.ts +3 -1
package/CHANGELOG.md
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * as logger from "./logger";
|
|
|
14
14
|
export * from "./loop-phase";
|
|
15
15
|
export * from "./mermaid-ascii";
|
|
16
16
|
export * from "./mime";
|
|
17
|
+
export * from "./path";
|
|
17
18
|
export * from "./path-tree";
|
|
18
19
|
export * from "./peek-file";
|
|
19
20
|
export * as postmortem from "./postmortem";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-utils",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.6",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@oh-my-pi/pi-natives": "16.2.
|
|
34
|
+
"@oh-my-pi/pi-natives": "16.2.6",
|
|
35
35
|
"handlebars": "^4.7.9",
|
|
36
36
|
"winston": "^3.19.0",
|
|
37
37
|
"winston-daily-rotate-file": "^5.0.0"
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * as logger from "./logger";
|
|
|
14
14
|
export * from "./loop-phase";
|
|
15
15
|
export * from "./mermaid-ascii";
|
|
16
16
|
export * from "./mime";
|
|
17
|
+
export * from "./path";
|
|
17
18
|
export * from "./path-tree";
|
|
18
19
|
export * from "./peek-file";
|
|
19
20
|
export * as postmortem from "./postmortem";
|
package/src/path.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const WINDOWS_DRIVE_EXTENDED_PREFIX = /^\\\\[?]\\([A-Za-z]:[\\/].*)$/;
|
|
2
|
+
const WINDOWS_UNC_EXTENDED_PREFIX = /^\\\\[?]\\UNC[\\/]([^\\/]+)[\\/](.+)$/i;
|
|
3
|
+
const WINDOWS_DRIVE_EXTENDED_FORWARD_PREFIX = /^\/\/[?]\/([A-Za-z]:\/.*)$/;
|
|
4
|
+
const WINDOWS_UNC_EXTENDED_FORWARD_PREFIX = /^\/\/[?]\/UNC\/([^/]+)\/(.+)$/i;
|
|
5
|
+
const WINDOWS_DRIVE_NT_PREFIX = /^\\\\[?][?]\\([A-Za-z]:[\\/].*)$/;
|
|
6
|
+
const WINDOWS_UNC_NT_PREFIX = /^\\\\[?][?]\\UNC[\\/]([^\\/]+)[\\/](.+)$/i;
|
|
7
|
+
|
|
8
|
+
/** Removes Win32 extended-length prefixes before passing paths to Bun APIs. */
|
|
9
|
+
export function stripWindowsExtendedLengthPathPrefix(
|
|
10
|
+
filePath: string,
|
|
11
|
+
platform: NodeJS.Platform = process.platform,
|
|
12
|
+
): string {
|
|
13
|
+
if (platform !== "win32") return filePath;
|
|
14
|
+
|
|
15
|
+
const uncMatch = WINDOWS_UNC_EXTENDED_PREFIX.exec(filePath) ?? WINDOWS_UNC_NT_PREFIX.exec(filePath);
|
|
16
|
+
if (uncMatch) return `\\\\${uncMatch[1]}\\${uncMatch[2]}`;
|
|
17
|
+
|
|
18
|
+
const driveMatch = WINDOWS_DRIVE_EXTENDED_PREFIX.exec(filePath) ?? WINDOWS_DRIVE_NT_PREFIX.exec(filePath);
|
|
19
|
+
if (driveMatch) return driveMatch[1];
|
|
20
|
+
|
|
21
|
+
const forwardUncMatch = WINDOWS_UNC_EXTENDED_FORWARD_PREFIX.exec(filePath);
|
|
22
|
+
if (forwardUncMatch) return `//${forwardUncMatch[1]}/${forwardUncMatch[2]}`;
|
|
23
|
+
|
|
24
|
+
const forwardDriveMatch = WINDOWS_DRIVE_EXTENDED_FORWARD_PREFIX.exec(filePath);
|
|
25
|
+
if (forwardDriveMatch) return forwardDriveMatch[1];
|
|
26
|
+
|
|
27
|
+
return filePath;
|
|
28
|
+
}
|
package/src/worker-host.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { stripWindowsExtendedLengthPathPrefix } from "./path";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Main-module path declared by self-dispatching CLI entrypoints — entries
|
|
3
5
|
* whose top-level argv handling routes hidden `__omp_*` worker selectors.
|
|
@@ -10,7 +12,7 @@ let workerHostMain: string | null = null;
|
|
|
10
12
|
|
|
11
13
|
/** Called by CLI entrypoints whose main module dispatches worker argv selectors. */
|
|
12
14
|
export function declareWorkerHostEntry(): void {
|
|
13
|
-
workerHostMain = Bun.main;
|
|
15
|
+
workerHostMain = stripWindowsExtendedLengthPathPrefix(Bun.main);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
/** Main-module path of the self-dispatching CLI host, or null outside it. */
|