diff --git a/src/tools/glob/cli.ts b/src/tools/glob/cli.ts index b621383a..99613338 100644 --- a/src/tools/glob/cli.ts +++ b/src/tools/glob/cli.ts @@ -1,3 +1,4 @@ +import { resolve } from "node:path" import { spawn } from "bun" import { resolveGrepCli, @@ -119,10 +120,9 @@ async function runRgFilesInternal( if (isRg) { const args = buildRgArgs(options) - const paths = options.paths?.length ? options.paths : ["."] - args.push(...paths) + cwd = options.paths?.[0] || "." + args.push(".") command = [cli.path, ...args] - cwd = undefined } else if (isWindows) { command = buildPowerShellCommand(options) cwd = undefined @@ -177,7 +177,7 @@ async function runRgFilesInternal( let filePath: string if (isRg) { - filePath = line + filePath = cwd ? resolve(cwd, line) : line } else if (isWindows) { filePath = line.trim() } else { diff --git a/src/tools/glob/tools.ts b/src/tools/glob/tools.ts index d808377b..cdfa983b 100644 --- a/src/tools/glob/tools.ts +++ b/src/tools/glob/tools.ts @@ -29,12 +29,11 @@ export function createGlobTools(ctx: PluginInput): Record const dir = typeof runtimeCtx.directory === "string" ? runtimeCtx.directory : ctx.directory const searchPath = args.path ? resolve(dir, args.path) : dir - const paths = [searchPath] const result = await runRgFiles( { pattern: args.pattern, - paths, + paths: [searchPath], }, cli )