|
1 | 1 | // @effect-diagnostics globalTimers:off |
2 | 2 | // The SDK owns process shutdown; native deadlines cover initialize before an Effect resource exists. |
3 | | -// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.realPath is Node's JS realpath; museWorkspaceRoot needs the native one. |
| 3 | +// @effect-diagnostics-next-line nodeBuiltinImport:off -- FileSystem.realPath is Node's JS realpath; museCanonicalPath needs the native one. |
4 | 4 | import * as NodeFSP from "node:fs/promises"; |
5 | 5 |
|
6 | 6 | import { |
@@ -69,14 +69,27 @@ export function museVerbatimPath(path: string): string { |
69 | 69 | } |
70 | 70 |
|
71 | 71 | /** |
72 | | - * On Windows Muse rejects anything but the verbatim canonical path, true case |
73 | | - * and long names included, so resolve with the native realpath, which unlike |
74 | | - * FileSystem.realPath fixes case and expands 8.3 names. Muse itself still |
75 | | - * starts in the plain path: the `muse.cmd` launcher runs under cmd.exe, which |
76 | | - * cannot use a verbatim directory. |
| 72 | + * A path in the canonical form Muse reports and requires: symlinks resolved |
| 73 | + * and, on case-insensitive filesystems, the case that is on disk. The |
| 74 | + * promises realpath is Node's native one, which fixes case (and expands |
| 75 | + * Windows 8.3 names); FileSystem.realPath is the JS one, which keeps the case |
| 76 | + * it is given, so `…/EEVEE` survives it when the directory is `eevee` and |
| 77 | + * Muse then rejects the root. An unresolvable path is returned unchanged. |
| 78 | + */ |
| 79 | +export const museCanonicalPath = Effect.fn("museCanonicalPath")(function* (path: string) { |
| 80 | + return yield* Effect.tryPromise(() => NodeFSP.realpath(path)).pipe( |
| 81 | + Effect.orElseSucceed(() => path), |
| 82 | + ); |
| 83 | +}); |
| 84 | + |
| 85 | +/** |
| 86 | + * A workspace root in the form `turn/start` accepts: the canonical path, in |
| 87 | + * verbatim form on Windows, where Muse rejects anything else. Muse itself |
| 88 | + * still starts in the plain path: the `muse.cmd` launcher runs under cmd.exe, |
| 89 | + * which cannot use a verbatim directory. |
77 | 90 | */ |
78 | 91 | export const museWorkspaceRoot = Effect.fn("museWorkspaceRoot")(function* (path: string) { |
79 | | - if ((yield* HostProcess.Platform) !== "win32") return path; |
| 92 | + if ((yield* HostProcess.Platform) !== "win32") return yield* museCanonicalPath(path); |
80 | 93 | const canonical = yield* Effect.tryPromise(() => NodeFSP.realpath(path)).pipe( |
81 | 94 | // A verbatim path takes `/` literally, so an unresolved root needs Windows separators. |
82 | 95 | Effect.orElseSucceed(() => path.replaceAll("/", "\\")), |
|
0 commit comments