Skip to content

Commit 09e9dc6

Browse files
authored
Don't ignore default jobs = N in Werkfile (#75)
1 parent 1278493 commit 09e9dc6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

werk-cli/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,19 +674,19 @@ pub fn get_workspace_dir<'a>(
674674
}
675675

676676
pub fn get_workspace_settings(
677-
config: &werk_runner::ir::Defaults,
677+
defaults: &werk_runner::ir::Defaults,
678678
args: &Args,
679679
workspace_dir: &Absolute<std::path::Path>,
680680
color_stdout: ColorOutputKind,
681681
) -> Result<WorkspaceSettings, Error> {
682682
let out_dir = find_output_directory(
683683
workspace_dir,
684684
args.output_dir.as_deref(),
685-
config.output_directory.as_deref(),
685+
defaults.output_directory.as_deref(),
686686
)?;
687687

688688
let mut settings = WorkspaceSettings::new(workspace_dir.to_owned());
689-
settings.jobs = args.jobs.unwrap_or_else(num_cpus::get);
689+
settings.jobs = args.jobs.or(defaults.jobs).unwrap_or_else(num_cpus::get);
690690
settings.output_directory = out_dir;
691691
for def in &args.define {
692692
let Some((key, value)) = def.split_once('=') else {

werk-runner/ir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub struct Defaults {
190190
pub explain: Option<bool>,
191191
pub verbose: Option<bool>,
192192
pub watch_delay: Option<i32>,
193-
pub jobs: Option<i32>,
193+
pub jobs: Option<usize>,
194194
pub edition: Edition,
195195
}
196196

@@ -216,7 +216,7 @@ impl Defaults {
216216
ast::DefaultStmt::Explain(entry) => defaults.explain = Some(entry.value.1),
217217
ast::DefaultStmt::Verbose(entry) => defaults.verbose = Some(entry.value.1),
218218
ast::DefaultStmt::WatchDelay(entry) => defaults.watch_delay = Some(entry.value.1),
219-
ast::DefaultStmt::Jobs(entry) => defaults.jobs = Some(entry.value.1),
219+
ast::DefaultStmt::Jobs(entry) => defaults.jobs = entry.value.1.try_into().ok(),
220220
ast::DefaultStmt::Edition(entry) => {
221221
if entry.value.1 == "v1" {
222222
defaults.edition = Edition::V1;

0 commit comments

Comments
 (0)