chore: effect pattern lint infrastructure (#35210)
This commit is contained in:
parent
1b88ff8d53
commit
1401901529
70 changed files with 524 additions and 234 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { NodeFileSystem } from "@effect/platform-node"
|
||||
import { dirname, isAbsolute, join, relative, resolve as pathResolve, sep } from "path"
|
||||
import path, { dirname, isAbsolute, join, relative, sep } from "path"
|
||||
import { realpathSync } from "fs"
|
||||
import * as NFS from "fs/promises"
|
||||
import { readdir } from "fs/promises"
|
||||
import { lookup } from "mime-types"
|
||||
import { Context, Effect, FileSystem, Layer, Schema } from "effect"
|
||||
import type { PlatformError } from "effect/PlatformError"
|
||||
|
|
@ -78,7 +78,7 @@ export namespace FSUtil {
|
|||
const readDirectoryEntries = Effect.fn("FileSystem.readDirectoryEntries")(function* (dirPath: string) {
|
||||
return yield* Effect.tryPromise({
|
||||
try: async () => {
|
||||
const entries = await NFS.readdir(dirPath, { withFileTypes: true })
|
||||
const entries = await readdir(dirPath, { withFileTypes: true })
|
||||
return entries.map(
|
||||
(e): DirEntry => ({
|
||||
name: e.name,
|
||||
|
|
@ -90,8 +90,8 @@ export namespace FSUtil {
|
|||
})
|
||||
})
|
||||
|
||||
const resolve = Effect.fn("FileSystem.resolve")(function* (path: string) {
|
||||
const resolved = pathResolve(windowsPath(path))
|
||||
const resolve = Effect.fn("FileSystem.resolve")(function* (input: string) {
|
||||
const resolved = path.resolve(windowsPath(input))
|
||||
return yield* fs.realPath(resolved).pipe(
|
||||
Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(resolved)),
|
||||
Effect.orDie,
|
||||
|
|
@ -219,7 +219,7 @@ export namespace FSUtil {
|
|||
|
||||
export function normalizePath(p: string): string {
|
||||
if (process.platform !== "win32") return p
|
||||
const resolved = pathResolve(windowsPath(p))
|
||||
const resolved = path.resolve(windowsPath(p))
|
||||
try {
|
||||
return realpathSync.native(resolved)
|
||||
} catch {
|
||||
|
|
@ -237,7 +237,7 @@ export namespace FSUtil {
|
|||
}
|
||||
|
||||
export function resolve(p: string): string {
|
||||
const resolved = pathResolve(windowsPath(p))
|
||||
const resolved = path.resolve(windowsPath(p))
|
||||
try {
|
||||
return normalizePath(realpathSync(resolved))
|
||||
} catch (e: any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue