Skip to content

Commit 90356f5

Browse files
committed
fix(config): use pnpm dlx in pnpm projects
Closes #310
1 parent 688f267 commit 90356f5

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/rcfile/javascript.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,27 @@ pub fn from_javascript_path(file_path: &Path) -> Result<Rcfile, RcfileError> {
6969
"#
7070
);
7171

72-
// Prefer bunx if a Bun lockfile exists in the same directory as the config
7372
let dir = file_path.parent().unwrap_or_else(|| Path::new("."));
74-
let use_bunx = dir.join("bun.lock").exists() || dir.join("bun.lockb").exists();
75-
let runner = if use_bunx { "bunx" } else { "npx" };
73+
let runner = if dir.join("pnpm-lock.yaml").exists() || dir.join("pnpm-workspace.yaml").exists() {
74+
"pnpm"
75+
} else if dir.join("bun.lock").exists() || dir.join("bun.lockb").exists() {
76+
"bunx"
77+
} else {
78+
"npx"
79+
};
80+
81+
let mut args = vec![];
82+
83+
if runner == "pnpm" {
84+
args.push("dlx");
85+
}
86+
87+
args.push("tsx");
88+
args.push("-e");
89+
args.push(&nodejs_script);
7690

7791
Command::new(runner)
78-
.args(["tsx", "-e", &nodejs_script])
92+
.args(args)
7993
.current_dir(file_path.parent().unwrap_or_else(|| Path::new(".")))
8094
.output()
8195
.map_err(RcfileError::NodeJsExecutionFailed)

0 commit comments

Comments
 (0)