Added recursion modularity to ripgrep
This commit is contained in:
parent
ae091b8dea
commit
5c30db838c
|
@ -2,11 +2,15 @@ import { rgPath } from "@vscode/ripgrep";
|
||||||
import { spawn } from "child_process";
|
import { spawn } from "child_process";
|
||||||
import { once } from "events";
|
import { once } from "events";
|
||||||
|
|
||||||
|
// TODO: At present, this function is always called recursively in the current directory via process.cwd()
|
||||||
|
// I might need to add '--max-depth 1' to account for someone nesting sentinel directories
|
||||||
|
// syntax is 'rg --max-depth 1'
|
||||||
|
|
||||||
// TODO: At present there's absolutely no point using typescript for this module.
|
// TODO: At present there's absolutely no point using typescript for this module.
|
||||||
// I need to figure out how returning Promise values works when implemented with `spawn`
|
// I need to figure out how returning Promise values works when implemented with `spawn`
|
||||||
export async function ripGrep(phrase: string) {
|
export async function ripGrep(phrase: string, dir: string=process.cwd(), recursiveSearch:boolean=true) {
|
||||||
try {
|
try {
|
||||||
const rg = spawn(rgPath, [phrase, process.cwd()]);
|
const rg = spawn(rgPath, [phrase, dir]);
|
||||||
let exitCode;
|
let exitCode;
|
||||||
// Capture ripgrep exit code and return it after the process finishes
|
// Capture ripgrep exit code and return it after the process finishes
|
||||||
//exit code for 'no match' is 1 for ripgrep
|
//exit code for 'no match' is 1 for ripgrep
|
||||||
|
|
BIN
totem-0.0.1.tgz
BIN
totem-0.0.1.tgz
Binary file not shown.
Loading…
Reference in a new issue