ripgrep 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -14
- package/lib/_rg.wasm.mjs +4 -4
- package/lib/_wasi.mjs +38 -1
- package/lib/index.mjs +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npx ripgrep TODO src/
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Or install globally:
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
# or install globally
|
|
14
11
|
npm i -g ripgrep
|
|
15
12
|
rg TODO src/
|
|
16
13
|
```
|
|
@@ -18,10 +15,15 @@ rg TODO src/
|
|
|
18
15
|
## Programmatic API
|
|
19
16
|
|
|
20
17
|
```js
|
|
21
|
-
import { ripgrep } from "ripgrep";
|
|
18
|
+
import { ripgrep, rgPath } from "ripgrep";
|
|
22
19
|
|
|
20
|
+
// Run ripgrep programmatically
|
|
23
21
|
const { code } = await ripgrep(["--json", "TODO", "src"]);
|
|
24
22
|
// 0 = matches found, 1 = no matches, 2 = error
|
|
23
|
+
|
|
24
|
+
// Or spawn as a child process (drop-in for vscode-ripgrep)
|
|
25
|
+
import { spawn } from "node:child_process";
|
|
26
|
+
spawn(rgPath, ["TODO", "src"], { stdio: "inherit" });
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
### `ripgrep(args, options)`
|
|
@@ -33,18 +35,11 @@ Options:
|
|
|
33
35
|
- `env` — environment variables passed to the WASI instance (default: `process.env`).
|
|
34
36
|
- `preopens` — WASI preopened directories mapping guest paths to host paths (default: `{ ".": process.cwd() }`). Required for ripgrep to see any files on disk.
|
|
35
37
|
- `returnOnExit` — when `true`, `proc_exit` returns the exit code instead of terminating the process (default: `true`).
|
|
36
|
-
- `nodeWasi` — use Node's built-in `node:wasi` instead of the bundled WASI shim
|
|
38
|
+
- `nodeWasi` — use Node's built-in `node:wasi` instead of the bundled WASI shim. Enabled by default on Node.js for best performance; automatically disabled on Bun and Deno where `node:wasi` is not available, falling back to the bundled shim. Can also be forced on via `ZIGREP_NODE_WASI=1`.
|
|
37
39
|
|
|
38
40
|
### `rgPath`
|
|
39
41
|
|
|
40
|
-
Absolute filesystem path to a JS shim that runs ripgrep via `ripgrep`. Drop-in replacement for `rgPath` from `vscode-ripgrep` / `@vscode/ripgrep`-style consumers that spawn the binary directly
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
import { spawn } from "node:child_process";
|
|
44
|
-
import { rgPath } from "ripgrep";
|
|
45
|
-
|
|
46
|
-
spawn(rgPath, ["TODO", "src"], { stdio: "inherit" });
|
|
47
|
-
```
|
|
42
|
+
Absolute filesystem path to a JS shim that runs ripgrep via `ripgrep`. Drop-in replacement for `rgPath` from `vscode-ripgrep` / `@vscode/ripgrep`-style consumers that spawn the binary directly.
|
|
48
43
|
|
|
49
44
|
## How it works
|
|
50
45
|
|