Buckets:
| import { describe, expect } from "bun:test" | |
| import fs from "fs/promises" | |
| import path from "path" | |
| import { Effect } from "effect" | |
| import { Ripgrep } from "@opencode-ai/core/ripgrep" | |
| import { AbsolutePath, RelativePath } from "@opencode-ai/core/schema" | |
| import { tmpdir } from "../fixture/tmpdir" | |
| import { testEffect } from "../lib/effect" | |
| const it = testEffect(Ripgrep.defaultLayer) | |
| const withTmp = <A, E, R>(f: (directory: AbsolutePath) => Effect.Effect<A, E, R>) => | |
| Effect.acquireRelease( | |
| Effect.promise(() => tmpdir()), | |
| (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), | |
| ).pipe(Effect.flatMap((tmp) => f(AbsolutePath.make(tmp.path)))) | |
| describe("Ripgrep", () => { | |
| it.live("globs files as an array", () => | |
| withTmp((cwd) => | |
| Effect.gen(function* () { | |
| yield* Effect.promise(() => fs.mkdir(path.join(cwd, "src"))) | |
| yield* Effect.promise(() => fs.writeFile(path.join(cwd, "src", "match.ts"), "needle\n")) | |
| const result = yield* (yield* Ripgrep.Service).glob({ cwd, pattern: "**/*.ts", limit: 10 }) | |
| expect(result.map((item) => item.path)).toEqual([RelativePath.make(path.join("src", "match.ts"))]) | |
| }), | |
| ), | |
| ) | |
| it.live("greps files with include filtering", () => | |
| withTmp((cwd) => | |
| Effect.gen(function* () { | |
| yield* Effect.promise(() => fs.mkdir(path.join(cwd, "src"))) | |
| yield* Effect.promise(() => fs.writeFile(path.join(cwd, "src", "match.ts"), "needle\n")) | |
| yield* Effect.promise(() => fs.writeFile(path.join(cwd, "src", "skip.txt"), "needle\n")) | |
| const result = yield* (yield* Ripgrep.Service).grep({ cwd, pattern: "needle", include: "*.ts", limit: 10 }) | |
| expect(result).toHaveLength(1) | |
| expect(result[0]?.entry.path).toBe(RelativePath.make(path.join("src", "match.ts"))) | |
| expect(result[0]?.submatches[0]?.text).toBe("needle") | |
| }), | |
| ), | |
| ) | |
| }) | |
Xet Storage Details
- Size:
- 1.88 kB
- Xet hash:
- d8b00cae4cd8105ec9d5f7c7f1d912a87ec186d0ecfa3e1de5fe0319ca24df85
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.