mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(cli): add --threads 1 option for rayon to use only 1 threads
This commit is contained in:
parent
48736e53af
commit
04592b3e4f
2 changed files with 12 additions and 1 deletions
|
|
@ -3,7 +3,7 @@ mod lint;
|
|||
mod result;
|
||||
mod walk;
|
||||
|
||||
use clap::Command;
|
||||
use clap::{Arg, Command};
|
||||
|
||||
use crate::lint::lint_command;
|
||||
pub use crate::{
|
||||
|
|
@ -22,4 +22,10 @@ pub fn command() -> Command {
|
|||
.subcommand_required(true)
|
||||
.arg_required_else_help(true)
|
||||
.subcommand(lint_command())
|
||||
.arg(
|
||||
Arg::new("threads")
|
||||
.long("threads")
|
||||
.value_parser(clap::value_parser!(usize))
|
||||
.help("Number of threads to use. Set to 1 for using only 1 CPU core."),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use oxc_cli::{command, CliRunResult, LintOptions, LintRunner};
|
|||
|
||||
fn main() -> CliRunResult {
|
||||
let matches = command().get_matches();
|
||||
|
||||
if let Some(threads) = matches.get_one::<usize>("threads") {
|
||||
rayon::ThreadPoolBuilder::new().num_threads(*threads).build_global().unwrap();
|
||||
}
|
||||
|
||||
let Some((subcommand, matches)) = matches.subcommand() else {
|
||||
return CliRunResult::None
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue