@oh-my-pi/pi-utils 18.12.2 → 18.12.3
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/dist/types/dirs.d.ts +8 -1
- package/package.json +2 -2
- package/src/dirs.ts +23 -2
package/dist/types/dirs.d.ts
CHANGED
|
@@ -44,7 +44,14 @@ export declare function normalizeProfileName(profile: string | undefined): strin
|
|
|
44
44
|
export declare function resolveProfileEnv(omp: string | undefined, pi: string | undefined): string | undefined;
|
|
45
45
|
/** Profile-independent config root (~/.omp), shared by every omp profile. */
|
|
46
46
|
export declare function getBaseConfigRoot(): string;
|
|
47
|
-
export
|
|
47
|
+
export interface EquivalentPathOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a path that does not exist yet through its deepest existing ancestor, keeping the
|
|
50
|
+
* missing suffix, so a symlinked parent canonicalizes the same before and after the path appears.
|
|
51
|
+
*/
|
|
52
|
+
throughMissing?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function resolveEquivalentPath(inputPath: string, options?: EquivalentPathOptions): string;
|
|
48
55
|
export declare function normalizePathForComparison(inputPath: string): string;
|
|
49
56
|
/**
|
|
50
57
|
* Compare paths already normalized by {@link normalizePathForComparison}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-utils",
|
|
3
|
-
"version": "18.12.
|
|
3
|
+
"version": "18.12.3",
|
|
4
4
|
"description": "Shared utilities for pi packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@oh-my-pi/pi-natives": "18.12.
|
|
60
|
+
"@oh-my-pi/pi-natives": "18.12.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/bun": "^1.3.14"
|
package/src/dirs.ts
CHANGED
|
@@ -160,12 +160,33 @@ function standardizeProjectPath(p: string): string {
|
|
|
160
160
|
return process.platform === "win32" ? expandWindowsLongPath(p) : standardizeMacOSPath(p);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
export
|
|
163
|
+
export interface EquivalentPathOptions {
|
|
164
|
+
/**
|
|
165
|
+
* Resolve a path that does not exist yet through its deepest existing ancestor, keeping the
|
|
166
|
+
* missing suffix, so a symlinked parent canonicalizes the same before and after the path appears.
|
|
167
|
+
*/
|
|
168
|
+
throughMissing?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function resolveEquivalentPath(inputPath: string, options?: EquivalentPathOptions): string {
|
|
164
172
|
const resolvedPath = path.resolve(inputPath);
|
|
165
173
|
try {
|
|
166
174
|
return fs.realpathSync(resolvedPath);
|
|
167
175
|
} catch {
|
|
168
|
-
return resolvedPath;
|
|
176
|
+
if (!options?.throughMissing) return resolvedPath;
|
|
177
|
+
}
|
|
178
|
+
const missing: string[] = [];
|
|
179
|
+
let current = resolvedPath;
|
|
180
|
+
for (;;) {
|
|
181
|
+
const parent = path.dirname(current);
|
|
182
|
+
if (parent === current) return resolvedPath;
|
|
183
|
+
missing.unshift(path.basename(current));
|
|
184
|
+
current = parent;
|
|
185
|
+
try {
|
|
186
|
+
return path.join(fs.realpathSync(current), ...missing);
|
|
187
|
+
} catch {
|
|
188
|
+
// Keep walking: a higher ancestor may exist.
|
|
189
|
+
}
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
192
|
|