@opencode/util 0.0.0-dev-1348 → 0.0.0-dev-1350
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/fs-util.d.ts +2 -1
- package/dist/fs-util.js +6 -11
- package/package.json +1 -1
package/dist/fs-util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PlatformPath } from "path";
|
|
1
2
|
import { Context, Effect, FileSystem, Layer, Schema } from "effect";
|
|
2
3
|
import type { PlatformError } from "effect/PlatformError";
|
|
3
4
|
import { Glob } from "./glob.js";
|
|
@@ -48,6 +49,6 @@ export declare namespace FSUtil {
|
|
|
48
49
|
export const ignoredDirectories: string[];
|
|
49
50
|
export const ignoreGlobs: string[];
|
|
50
51
|
export function overlaps(a: string, b: string): boolean;
|
|
51
|
-
export function contains(parent: string, child: string): boolean;
|
|
52
|
+
export function contains(parent: string, child: string, platform?: PlatformPath): boolean;
|
|
52
53
|
export {};
|
|
53
54
|
}
|
package/dist/fs-util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path, { dirname,
|
|
1
|
+
import path, { dirname, join } from "path";
|
|
2
2
|
import { realpathSync } from "fs";
|
|
3
3
|
import { lookup } from "mime-types";
|
|
4
4
|
import { Context, Effect, FileSystem, Layer, Schema } from "effect";
|
|
@@ -29,9 +29,7 @@ export var FSUtil;
|
|
|
29
29
|
return yield* fs.exists(path).pipe(Effect.orElseSucceed(() => false));
|
|
30
30
|
});
|
|
31
31
|
const readFileStringSafe = Effect.fn("FileSystem.readFileStringSafe")(function* (path) {
|
|
32
|
-
return yield* fs
|
|
33
|
-
.readFileString(path)
|
|
34
|
-
.pipe(Effect.catchIf((error) => error.reason._tag === "NotFound" || isAccessDenied(error), () => Effect.undefined));
|
|
32
|
+
return yield* fs.readFileString(path).pipe(Effect.catchIf((error) => error.reason._tag === "NotFound" || isAccessDenied(error), () => Effect.undefined));
|
|
35
33
|
});
|
|
36
34
|
const isDir = Effect.fn("FileSystem.isDir")(function* (path) {
|
|
37
35
|
const info = yield* fs.stat(path).pipe(Effect.catch(() => Effect.void));
|
|
@@ -146,10 +144,7 @@ export var FSUtil;
|
|
|
146
144
|
if (error.reason._tag === "PermissionDenied")
|
|
147
145
|
return true;
|
|
148
146
|
const cause = error.reason.cause;
|
|
149
|
-
return (error.reason._tag === "Unknown" &&
|
|
150
|
-
cause instanceof globalThis.Error &&
|
|
151
|
-
"code" in cause &&
|
|
152
|
-
cause.code === "EPERM");
|
|
147
|
+
return (error.reason._tag === "Unknown" && cause instanceof globalThis.Error && "code" in cause && cause.code === "EPERM");
|
|
153
148
|
}
|
|
154
149
|
FSUtil.isAccessDenied = isAccessDenied;
|
|
155
150
|
// Pure helpers that don't need Effect (path manipulation, sync operations)
|
|
@@ -197,9 +192,9 @@ export var FSUtil;
|
|
|
197
192
|
return contains(a, b) || contains(b, a);
|
|
198
193
|
}
|
|
199
194
|
FSUtil.overlaps = overlaps;
|
|
200
|
-
function contains(parent, child) {
|
|
201
|
-
const result = relative(parent, child);
|
|
202
|
-
return result === "" || (!isAbsolute(result) && result !== ".." && !result.startsWith(`..${sep}`));
|
|
195
|
+
function contains(parent, child, platform = path) {
|
|
196
|
+
const result = platform.relative(parent, child);
|
|
197
|
+
return result === "" || (!platform.isAbsolute(result) && result !== ".." && !result.startsWith(`..${platform.sep}`));
|
|
203
198
|
}
|
|
204
199
|
FSUtil.contains = contains;
|
|
205
200
|
})(FSUtil || (FSUtil = {}));
|