@opencode-ai/util 0.0.0-next-16541 → 0.0.0-next-16543
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 +8 -10
- package/dist/fs-util.js +5 -17
- package/package.json +1 -1
package/dist/fs-util.d.ts
CHANGED
|
@@ -14,6 +14,12 @@ export declare namespace FSUtil {
|
|
|
14
14
|
readonly name: string;
|
|
15
15
|
readonly type: "file" | "directory" | "symlink" | "other";
|
|
16
16
|
}
|
|
17
|
+
export interface UpOptions {
|
|
18
|
+
readonly targets: string[];
|
|
19
|
+
readonly start: string;
|
|
20
|
+
readonly stop?: string;
|
|
21
|
+
readonly mode?: "all" | "first";
|
|
22
|
+
}
|
|
17
23
|
export interface Interface extends FileSystem.FileSystem {
|
|
18
24
|
readonly isDir: (path: string) => Effect.Effect<boolean>;
|
|
19
25
|
readonly isFile: (path: string) => Effect.Effect<boolean>;
|
|
@@ -26,11 +32,7 @@ export declare namespace FSUtil {
|
|
|
26
32
|
readonly readDirectoryEntries: (path: string) => Effect.Effect<DirEntry[], Error>;
|
|
27
33
|
readonly resolve: (path: string) => Effect.Effect<string>;
|
|
28
34
|
readonly findUp: (target: string, start: string, stop?: string) => Effect.Effect<string[], Error>;
|
|
29
|
-
readonly up: (options:
|
|
30
|
-
targets: string[];
|
|
31
|
-
start: string;
|
|
32
|
-
stop?: string;
|
|
33
|
-
}) => Effect.Effect<string[], Error>;
|
|
35
|
+
readonly up: (options: UpOptions) => Effect.Effect<string[], Error>;
|
|
34
36
|
readonly globUp: (pattern: string, start: string, stop?: string) => Effect.Effect<string[], Error>;
|
|
35
37
|
readonly scan: (pattern: string, options?: Glob.Options) => Effect.Effect<string[], Error>;
|
|
36
38
|
readonly globMatch: (pattern: string, filepath: string) => boolean;
|
|
@@ -50,11 +52,7 @@ export declare namespace FSUtil {
|
|
|
50
52
|
readonly readDirectoryEntries: (path: string) => Effect.Effect<DirEntry[], Error, Service>;
|
|
51
53
|
readonly resolve: (path: string) => Effect.Effect<string, never, Service>;
|
|
52
54
|
readonly findUp: (target: string, start: string, stop?: string | undefined) => Effect.Effect<string[], Error, Service>;
|
|
53
|
-
readonly up: (options:
|
|
54
|
-
targets: string[];
|
|
55
|
-
start: string;
|
|
56
|
-
stop?: string;
|
|
57
|
-
}) => Effect.Effect<string[], Error, Service>;
|
|
55
|
+
readonly up: (options: UpOptions) => Effect.Effect<string[], Error, Service>;
|
|
58
56
|
readonly globUp: (pattern: string, start: string, stop?: string | undefined) => Effect.Effect<string[], Error, Service>;
|
|
59
57
|
readonly scan: (pattern: string, options?: Glob.Options | undefined) => Effect.Effect<string[], Error, Service>;
|
|
60
58
|
readonly access: (path: string, options?: {
|
package/dist/fs-util.js
CHANGED
|
@@ -92,30 +92,17 @@ export var FSUtil;
|
|
|
92
92
|
catch: (cause) => new FileSystemError({ method: "glob", cause }),
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
|
-
const findUp = Effect.fn("FileSystem.findUp")(function* (target, start, stop) {
|
|
96
|
-
const result = [];
|
|
97
|
-
let current = start;
|
|
98
|
-
while (true) {
|
|
99
|
-
const search = join(current, target);
|
|
100
|
-
if (yield* fs.exists(search))
|
|
101
|
-
result.push(search);
|
|
102
|
-
if (stop === current)
|
|
103
|
-
break;
|
|
104
|
-
const parent = dirname(current);
|
|
105
|
-
if (parent === current)
|
|
106
|
-
break;
|
|
107
|
-
current = parent;
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
});
|
|
111
95
|
const up = Effect.fn("FileSystem.up")(function* (options) {
|
|
112
96
|
const result = [];
|
|
113
97
|
let current = options.start;
|
|
114
98
|
while (true) {
|
|
115
99
|
for (const target of options.targets) {
|
|
116
100
|
const search = join(current, target);
|
|
117
|
-
if (yield* fs.exists(search))
|
|
101
|
+
if (yield* fs.exists(search)) {
|
|
118
102
|
result.push(search);
|
|
103
|
+
if (options.mode === "first")
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
119
106
|
}
|
|
120
107
|
if (options.stop === current)
|
|
121
108
|
break;
|
|
@@ -126,6 +113,7 @@ export var FSUtil;
|
|
|
126
113
|
}
|
|
127
114
|
return result;
|
|
128
115
|
});
|
|
116
|
+
const findUp = Effect.fn("FileSystem.findUp")((target, start, stop) => up({ targets: [target], start, stop }));
|
|
129
117
|
const globUp = Effect.fn("FileSystem.globUp")(function* (pattern, start, stop) {
|
|
130
118
|
const result = [];
|
|
131
119
|
let current = start;
|