@effect/platform-node-shared
Advanced tools
Comparing version
@@ -310,4 +310,6 @@ "use strict"; | ||
// == watch | ||
const watchNode = path => Stream.asyncScoped(emit => Effect.acquireRelease(Effect.sync(() => { | ||
const watcher = NFS.watch(path, {}, (event, path) => { | ||
const watchNode = (path, options) => Stream.asyncScoped(emit => Effect.acquireRelease(Effect.sync(() => { | ||
const watcher = NFS.watch(path, { | ||
recursive: options?.recursive | ||
}, (event, path) => { | ||
if (!path) return; | ||
@@ -350,3 +352,3 @@ switch (event) { | ||
}), watcher => Effect.sync(() => watcher.close()))); | ||
const watch = (backend, path) => stat(path).pipe(Effect.map(stat => backend.pipe(Option.flatMap(_ => _.register(path, stat)), Option.getOrElse(() => watchNode(path)))), Stream.unwrap); | ||
const watch = (backend, path, options) => stat(path).pipe(Effect.map(stat => backend.pipe(Option.flatMap(_ => _.register(path, stat, options)), Option.getOrElse(() => watchNode(path, options)))), Stream.unwrap); | ||
// == writeFile | ||
@@ -393,4 +395,4 @@ const writeFile = (path, data, options) => Effect.async((resume, signal) => { | ||
utimes, | ||
watch(path) { | ||
return watch(backend, path); | ||
watch(path, options) { | ||
return watch(backend, path, options); | ||
}, | ||
@@ -397,0 +399,0 @@ writeFile |
@@ -60,3 +60,3 @@ "use strict"; | ||
const backend = /*#__PURE__*/FileSystem.WatchBackend.of({ | ||
register(path, stat) { | ||
register(path, stat, _options) { | ||
if (stat.type !== "Directory") { | ||
@@ -63,0 +63,0 @@ return Option.none(); |
@@ -303,4 +303,6 @@ import { effectify } from "@effect/platform/Effectify"; | ||
// == watch | ||
const watchNode = path => Stream.asyncScoped(emit => Effect.acquireRelease(Effect.sync(() => { | ||
const watcher = NFS.watch(path, {}, (event, path) => { | ||
const watchNode = (path, options) => Stream.asyncScoped(emit => Effect.acquireRelease(Effect.sync(() => { | ||
const watcher = NFS.watch(path, { | ||
recursive: options?.recursive | ||
}, (event, path) => { | ||
if (!path) return; | ||
@@ -343,3 +345,3 @@ switch (event) { | ||
}), watcher => Effect.sync(() => watcher.close()))); | ||
const watch = (backend, path) => stat(path).pipe(Effect.map(stat => backend.pipe(Option.flatMap(_ => _.register(path, stat)), Option.getOrElse(() => watchNode(path)))), Stream.unwrap); | ||
const watch = (backend, path, options) => stat(path).pipe(Effect.map(stat => backend.pipe(Option.flatMap(_ => _.register(path, stat, options)), Option.getOrElse(() => watchNode(path, options)))), Stream.unwrap); | ||
// == writeFile | ||
@@ -386,4 +388,4 @@ const writeFile = (path, data, options) => Effect.async((resume, signal) => { | ||
utimes, | ||
watch(path) { | ||
return watch(backend, path); | ||
watch(path, options) { | ||
return watch(backend, path, options); | ||
}, | ||
@@ -390,0 +392,0 @@ writeFile |
@@ -53,3 +53,3 @@ import * as Error from "@effect/platform/Error"; | ||
const backend = /*#__PURE__*/FileSystem.WatchBackend.of({ | ||
register(path, stat) { | ||
register(path, stat, _options) { | ||
if (stat.type !== "Directory") { | ||
@@ -56,0 +56,0 @@ return Option.none(); |
{ | ||
"name": "@effect/platform-node-shared", | ||
"version": "0.42.15", | ||
"version": "0.42.17", | ||
"description": "Unified interfaces for common platform-specific services", | ||
@@ -19,6 +19,6 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@effect/cluster": "^0.41.15", | ||
"@effect/platform": "^0.87.11", | ||
"@effect/rpc": "^0.64.12", | ||
"@effect/sql": "^0.40.12", | ||
"@effect/cluster": "^0.41.17", | ||
"@effect/platform": "^0.87.12", | ||
"@effect/rpc": "^0.64.13", | ||
"@effect/sql": "^0.40.13", | ||
"effect": "^3.16.12" | ||
@@ -25,0 +25,0 @@ }, |
@@ -538,7 +538,7 @@ import { effectify } from "@effect/platform/Effectify" | ||
const watchNode = (path: string) => | ||
const watchNode = (path: string, options?: FileSystem.WatchOptions) => | ||
Stream.asyncScoped<FileSystem.WatchEvent, Error.PlatformError>((emit) => | ||
Effect.acquireRelease( | ||
Effect.sync(() => { | ||
const watcher = NFS.watch(path, {}, (event, path) => { | ||
const watcher = NFS.watch(path, { recursive: options?.recursive }, (event, path) => { | ||
if (!path) return | ||
@@ -582,8 +582,12 @@ switch (event) { | ||
const watch = (backend: Option.Option<Context.Tag.Service<FileSystem.WatchBackend>>, path: string) => | ||
const watch = ( | ||
backend: Option.Option<Context.Tag.Service<FileSystem.WatchBackend>>, | ||
path: string, | ||
options?: FileSystem.WatchOptions | ||
) => | ||
stat(path).pipe( | ||
Effect.map((stat) => | ||
backend.pipe( | ||
Option.flatMap((_) => _.register(path, stat)), | ||
Option.getOrElse(() => watchNode(path)) | ||
Option.flatMap((_) => _.register(path, stat, options)), | ||
Option.getOrElse(() => watchNode(path, options)) | ||
) | ||
@@ -639,4 +643,4 @@ ), | ||
utimes, | ||
watch(path) { | ||
return watch(backend, path) | ||
watch(path, options) { | ||
return watch(backend, path, options) | ||
}, | ||
@@ -643,0 +647,0 @@ writeFile |
@@ -56,3 +56,3 @@ import * as Error from "@effect/platform/Error" | ||
const backend = FileSystem.WatchBackend.of({ | ||
register(path, stat) { | ||
register(path, stat, _options) { | ||
if (stat.type !== "Directory") { | ||
@@ -59,0 +59,0 @@ return Option.none() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
444254
0.14%6435
0.12%