From e4b7eb4469af0e7688a20ced2597117ebf7a217f Mon Sep 17 00:00:00 2001 From: TBroz15 <78770366+TBroz15@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:06:45 +0800 Subject: [PATCH] fix(compiler@other): :thread: default to 4 threads when there is no available CPU info This fix is for Termux Android when os.cpus() is not giving any CPU info. os.cpu() works but only ran on proot-distro. --- src/compiler/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index ca67fc4..f929da8 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -20,7 +20,8 @@ import type { PNGOptions, } from "./config/config.d.ts"; -const threads = cpus().length; +const availCPUs = cpus().length; +const threads = availCPUs === 0 ? 4 : availCPUs; interface FinalStats { compileTime: number;