Skip to content

Commit c1c8c57

Browse files
committed
fix: resolve paths for preopens
1 parent 2fa7aec commit c1c8c57

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/index.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fileURLToPath } from "node:url";
2-
import { isAbsolute } from "node:path";
2+
import { isAbsolute, resolve } from "node:path";
33

44
export const rgPath = fileURLToPath(new URL("./rg.mjs", import.meta.url));
55

@@ -25,8 +25,10 @@ export async function ripgrep(args = [], options = {}) {
2525
// without requiring the caller to manually configure preopens.
2626
const resolvedPreopens = { ...preopens };
2727
for (const arg of args) {
28-
if (isAbsolute(arg) && !(arg in resolvedPreopens)) {
29-
resolvedPreopens[arg] = arg;
28+
if (arg.startsWith("-")) continue;
29+
const absPath = isAbsolute(arg) ? arg : resolve(arg);
30+
if (!(absPath in resolvedPreopens)) {
31+
resolvedPreopens[absPath] = absPath;
3032
}
3133
}
3234

0 commit comments

Comments
 (0)