mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 02:57:36 +00:00
* Keep readable Markdown documents after traversal errors * Document partial Markdown listing behavior --------- Co-authored-by: Neil <neil@stably.ai>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { spawnBundledRipgrep } from '../ripgrep/bundled-ripgrep-spawn'
|
|
import { stopBundledRipgrep } from '../ripgrep/bundled-ripgrep-stop'
|
|
import { resolveBundledRipgrepWslRouting } from '../ripgrep/bundled-ripgrep-wsl-routing'
|
|
import {
|
|
collectMarkdownDocuments,
|
|
MARKDOWN_DOCUMENT_LISTING_ARGS
|
|
} from '../../shared/node-markdown-document-listing'
|
|
import type { MarkdownDocument } from '../../shared/filesystem-entry-types'
|
|
|
|
export async function listMarkdownDocuments(
|
|
rootPath: string,
|
|
options: { wslDistro?: string; signal?: AbortSignal } = {}
|
|
): Promise<MarkdownDocument[]> {
|
|
options.signal?.throwIfAborted()
|
|
const { wslDistro, wslDistroForOutput: distro } = resolveBundledRipgrepWslRouting(
|
|
rootPath,
|
|
options.wslDistro
|
|
)
|
|
const child = spawnBundledRipgrep(MARKDOWN_DOCUMENT_LISTING_ARGS, {
|
|
cwd: rootPath,
|
|
wslDistro,
|
|
wslDistroForOutput: distro,
|
|
stdio: ['ignore', 'pipe', 'pipe']
|
|
})
|
|
return collectMarkdownDocuments(child, rootPath, Boolean(distro), options.signal, {
|
|
allowPartialListing: true,
|
|
stopProcess: () => stopBundledRipgrep(child, Boolean(distro))
|
|
})
|
|
}
|