@effected/walker 0.7.0 → 0.9.0
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/Descend.js +4 -1
- package/README.md +1 -0
- package/index.d.ts +33 -22
- package/package.json +3 -3
- package/tsdoc-metadata.json +1 -1
package/Descend.js
CHANGED
|
@@ -84,7 +84,10 @@ const descendImpl = Effect.fn("Walker.descend")(function* (pattern, options) {
|
|
|
84
84
|
reason: "unreadableDirectory",
|
|
85
85
|
path: frame.relative
|
|
86
86
|
}));
|
|
87
|
-
if (onUnreadable === "record") unreadable.push(
|
|
87
|
+
if (onUnreadable === "record") unreadable.push({
|
|
88
|
+
path: frame.relative,
|
|
89
|
+
cause: error
|
|
90
|
+
});
|
|
88
91
|
return Effect.succeed([]);
|
|
89
92
|
}));
|
|
90
93
|
for (const entry of entries) {
|
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ The predicate can be expensive — reading and parsing a `package.json` to decid
|
|
|
86
86
|
- `Walker.firstMatch(candidates, predicate)` — the first candidate the predicate accepts. Absorbs each predicate failure individually and short-circuits at the first match.
|
|
87
87
|
- `Walker.findUpward(dirs, candidatesFor)` — the first existing path, directory-major: every candidate in the nearest directory is tried before ascending.
|
|
88
88
|
- `Walker.findRoot(dirs, isRoot)` — the nearest directory a marker predicate accepts. `firstMatch` where the candidate expansion is the identity.
|
|
89
|
+
- `descend(pattern, options)` — the file paths a compiled `@effected/glob` pattern selects under `cwd`, POSIX separators, sorted. `onUnreadable` decides what an unreadable directory mid-walk means: `"fail"` (the default) raises a typed `DescendError`, `"skip"` continues past it and forgets it, and `"record"` continues past it and returns a `DescendResult` — `{ matches, unreadable }`, where each `UnreadableDirectory` carries the directory's `cwd`-relative `path` and the `PlatformError` it failed with, so a report never has to re-read the directory to learn why. The walk base records as `path: ""`, and a directory that vanished mid-walk (`NotFound`) is a benign race, never recorded.
|
|
89
90
|
|
|
90
91
|
## License
|
|
91
92
|
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlobPattern, GlobPatternError, GlobPatternOptions } from "@effected/glob";
|
|
2
|
-
import { Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
2
|
+
import { Effect, FileSystem, Option, Path, PlatformError, Schema } from "effect";
|
|
3
3
|
//#region src/Descend.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Options for `descend`.
|
|
@@ -47,30 +47,41 @@ interface DescendRecordOptions extends Omit<DescendOptions, "onUnreadable"> {
|
|
|
47
47
|
readonly onUnreadable: "record";
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* `descend`
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* One directory `descend` could not read under `onUnreadable: "record"`: its
|
|
51
|
+
* `cwd`-relative path and the `PlatformError` that `readDirectory` failed
|
|
52
|
+
* with. The cause is the very failure the walk absorbed, so a caller that
|
|
53
|
+
* must report WHY a directory was unreadable never re-reads it.
|
|
54
54
|
*
|
|
55
55
|
* @public
|
|
56
56
|
*/
|
|
57
|
-
interface
|
|
58
|
-
/** Matching FILE paths relative to `cwd`, POSIX separators, sorted — identical in shape to the `"fail"`/`"skip"` success value. */
|
|
59
|
-
readonly matches: ReadonlyArray<string>;
|
|
57
|
+
interface UnreadableDirectory {
|
|
60
58
|
/**
|
|
61
|
-
*
|
|
59
|
+
* The directory's path relative to `cwd`, POSIX separators.
|
|
62
60
|
*
|
|
63
61
|
* @remarks
|
|
64
62
|
* **The walk base appears as the empty string `""`**, since its own
|
|
65
63
|
* `cwd`-relative path is empty — so an unreadable base yields
|
|
66
|
-
* `{ matches: [], unreadable: [""] }`. Code matching
|
|
67
|
-
* ordinary paths will not expect that; special-case it.
|
|
68
|
-
*
|
|
69
|
-
* No cause travels with an entry. A caller that must report WHY a directory
|
|
70
|
-
* was unreadable has to re-read it to obtain the `PlatformError`, which is
|
|
71
|
-
* a second syscall for information this walk had and discarded.
|
|
64
|
+
* `{ matches: [], unreadable: [{ path: "", cause }] }`. Code matching
|
|
65
|
+
* these entries as ordinary paths will not expect that; special-case it.
|
|
72
66
|
*/
|
|
73
|
-
readonly
|
|
67
|
+
readonly path: string;
|
|
68
|
+
/** The `readDirectory` failure, never `NotFound` (a vanished directory is a benign race and is not recorded). */
|
|
69
|
+
readonly cause: PlatformError.PlatformError;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* `descend`'s success value under `onUnreadable: "record"`: the matched
|
|
73
|
+
* FILE paths plus an {@link UnreadableDirectory} for every mid-walk
|
|
74
|
+
* directory whose `readDirectory` failed for a reason other than `NotFound`
|
|
75
|
+
* (a vanished directory stays a benign race in every mode and is never
|
|
76
|
+
* recorded).
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
interface DescendResult {
|
|
81
|
+
/** Matching FILE paths relative to `cwd`, POSIX separators, sorted — identical in shape to the `"fail"`/`"skip"` success value. */
|
|
82
|
+
readonly matches: ReadonlyArray<string>;
|
|
83
|
+
/** Directories that could not be read, each with its cause, in walk order. */
|
|
84
|
+
readonly unreadable: ReadonlyArray<UnreadableDirectory>;
|
|
74
85
|
}
|
|
75
86
|
declare const DescendError_base: Schema.Class<DescendError, Schema.TaggedStruct<"DescendError", {
|
|
76
87
|
/** The glob pattern's source text. */
|
|
@@ -95,11 +106,11 @@ export declare class DescendError extends DescendError_base {
|
|
|
95
106
|
/**
|
|
96
107
|
* Expand a compiled glob pattern against the filesystem under
|
|
97
108
|
* `onUnreadable: "record"`, resolving to a {@link DescendResult} — the
|
|
98
|
-
* matched FILE paths relative to `cwd` (POSIX separators, sorted) plus
|
|
99
|
-
*
|
|
100
|
-
* failed for a reason other than `NotFound`.
|
|
101
|
-
* such directory exactly as `"skip"` does; it
|
|
102
|
-
* discards the offending path.
|
|
109
|
+
* matched FILE paths relative to `cwd` (POSIX separators, sorted) plus an
|
|
110
|
+
* {@link UnreadableDirectory} — path and cause — for every mid-walk
|
|
111
|
+
* directory whose `readDirectory` failed for a reason other than `NotFound`.
|
|
112
|
+
* The walk continues past each such directory exactly as `"skip"` does; it
|
|
113
|
+
* never aborts and it never discards the offending path or its cause.
|
|
103
114
|
*
|
|
104
115
|
* @public
|
|
105
116
|
*/
|
|
@@ -355,5 +366,5 @@ export declare class Walker {
|
|
|
355
366
|
static readonly findRoot: <E, R>(dirs: ReadonlyArray<string>, isRoot: (dir: string) => Effect.Effect<boolean, E, R>) => Effect.Effect<Option.Option<string>, never, R>;
|
|
356
367
|
}
|
|
357
368
|
//#endregion
|
|
358
|
-
export type { AscendOptions, CompileAndExpandOptions, DescendOptions, DescendRecordOptions, DescendResult };
|
|
369
|
+
export type { AscendOptions, CompileAndExpandOptions, DescendOptions, DescendRecordOptions, DescendResult, UnreadableDirectory };
|
|
359
370
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/walker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Path traversal as Effect primitives: ascend a directory chain to the first matching candidate, or descend a tree expanding a glob against the filesystem.",
|
|
6
6
|
"keywords": [
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@effected/glob": "^0.
|
|
41
|
-
"effect": "4.0.0-rc.
|
|
40
|
+
"@effected/glob": "^0.6.0",
|
|
41
|
+
"effect": "4.0.0-rc.115"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=24.11.0"
|