mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 18:22:42 +00:00
fix(setup): preserve configuration directory requirements
This commit is contained in:
1 parent
235e8bc056
commit
01a725ecfa
4 files changed
+52
-10
No files matched your search
@@ -74,10 +74,17 @@ const canonicalRegularConfigPath = async (
|
||||
): Promise<string | undefined> => {
|
||||
if (fileSystem.realpath === undefined) return requestedPath;
|
||||
let ancestor = absoluteCallerPath(requestedPath);
|
||||
const directoryRequired =
|
||||
process.platform !== "win32" && ancestor.endsWith("/");
|
||||
const missing: string[] = [];
|
||||
while (true) {
|
||||
try {
|
||||
return join(await fileSystem.realpath(ancestor), ...missing);
|
||||
const canonical = join(await fileSystem.realpath(ancestor), ...missing);
|
||||
// Reconstructing missing children must retain the caller's directory
|
||||
// requirement; otherwise a missing `config.json/` becomes a writable file.
|
||||
return directoryRequired && !canonical.endsWith("/")
|
||||
? `${canonical}/`
|
||||
: canonical;
|
||||
} catch (cause: unknown) {
|
||||
if (!isAbsentPath(cause) || dirname(ancestor) === ancestor)
|
||||
return requestedPath;
|
||||
|
||||
Reference in new issue
Block a user