refactor: normalize filesystem boundary imports (#45730)

This commit is contained in:
Kit Langton
2026-08-27 22:31:15 -04:00
committed by GitHub
parent 762291b2a8
commit 04c9e01dad
4 changed files with 6 additions and 9 deletions
+5 -5
View File
@@ -7,16 +7,16 @@ import { FileSystem } from "@opencode-ai/schema/filesystem"
import { makeGlobalNode } from "@opencode-ai/util/effect/app-node"
import { Cause, Context, Effect, Layer, PubSub, RcMap, Schema, Stream } from "effect"
import { lazy } from "../util/lazy.js"
import { watch as watchFileSystem } from "node:fs"
import { watch } from "node:fs"
import path from "path"
import loadBinding from "./watcher-binding.js"
const SUBSCRIBE_TIMEOUT_MS = 10_000
export const Event = { Updated: FileSystem.Event.Changed }
const watcher = lazy((): typeof import("@parcel/watcher") | undefined => {
const watcher = lazy((): typeof ParcelWatcher | undefined => {
try {
return createWrapper(loadBinding()) as typeof import("@parcel/watcher")
return createWrapper(loadBinding()) as typeof ParcelWatcher
} catch {
return
}
@@ -192,7 +192,7 @@ export const nativeLayer = Layer.succeed(
if (input.type === "file") {
return Effect.sync(() => {
const directory = path.dirname(input.target)
const subscription = watchFileSystem(directory, { recursive: false }, (_event, file) => {
const subscription = watch(directory, { recursive: false }, (_event, file) => {
if (file && path.resolve(directory, file.toString()) !== input.target) return
input.publish({ path: input.target, type: "update" } satisfies Update)
})
@@ -218,7 +218,7 @@ export function configured(options?: Options) {
export const node = configured()
function subscribeDirectory(
native: typeof import("@parcel/watcher") | undefined,
native: typeof ParcelWatcher | undefined,
backend: ParcelWatcher.BackendType | undefined,
directory: string,
ignore: readonly string[],
+1 -1
View File
@@ -1,6 +1,6 @@
import path from "path"
import { Context, Effect, Layer, Stream } from "effect"
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http"
import { HttpClient, HttpClientRequest } from "effect/unstable/http"
import { ChildProcess } from "effect/unstable/process"
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
import { CrossSpawnSpawner } from "@opencode-ai/util/cross-spawn-spawner"
-2
View File
@@ -1,6 +1,4 @@
import type { NonEmptyReadonlyArray } from "effect/Array"
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem"
import * as NodePath from "@effect/platform-node/NodePath"
import * as NodeSink from "@effect/platform-node/NodeSink"
import * as NodeStream from "@effect/platform-node/NodeStream"
import { Deferred, Effect, Exit, FileSystem, Layer, Path, PlatformError, Predicate, Sink, Stream } from "effect"
-1
View File
@@ -1,4 +1,3 @@
import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem"
import path, { dirname, isAbsolute, join, relative, sep } from "path"
import { realpathSync } from "fs"
import { readdir } from "fs/promises"