Skip to content

Commit 4a4fce8

Browse files
committed
fix(linter): fix cli argument parsing (#14112)
fixes #14071 Simplify CLI argument collection by unconditionally skipping the first two entries in std::env::args_os(). This ensures correct handling in wrapper scenarios (e.g., Node.js invocations via npm/pnpm) where the conditional "node" check may fail, such as with version managers like asdf. Previously, mis-skipping could lead to wrapper script paths (potentially containing "..") being passed to the CLI parser, triggering validation errors. Since oxlint is not always distributed via the node (no longer a binary), we don't have to worry about the case where we're not running in node.
1 parent 5750077 commit 4a4fce8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

apps/oxlint/src/run.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,10 @@ fn lint_impl(load_plugin: JsLoadPluginCb, lint_file: JsLintFileCb) -> CliRunResu
6666
init_tracing();
6767
init_miette();
6868

69-
let mut args = std::env::args_os();
70-
// If first arg is `node`, also skip script path (`node script.js ...`).
71-
// Otherwise, just skip first arg (`oxlint ...`).
72-
if args.next().is_some_and(|arg| arg == "node") {
73-
args.next();
74-
}
75-
let args = args.collect::<Vec<_>>();
69+
// 1st arg is path to NodeJS binary.
70+
// 2nd arg is path to `oxlint/.bin/oxlint` (in released packages)
71+
// or `apps/oxlint/dist/cli.js` (in development).
72+
let args = std::env::args_os().skip(2).collect::<Vec<_>>();
7673

7774
let cmd = crate::cli::lint_command();
7875
let command = match cmd.run_inner(&*args) {

0 commit comments

Comments
 (0)