Skip to content

Commit

Permalink
fix: cpus length in a chroot environment (os.cpus()) (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Aug 15, 2018
1 parent 990fb1c commit 9375646
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TaskRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ export default class TaskRunner {
const { cache, parallel } = options;
this.cacheDir =
cache === true ? findCacheDir({ name: 'terser-webpack-plugin' }) : cache;
// In some cases cpus() returns undefined
// https://github.com/nodejs/node/issues/19022
const cpus = os.cpus() || { length: 1 };
this.maxConcurrentWorkers =
parallel === true
? os.cpus().length - 1
: Math.min(Number(parallel) || 0, os.cpus().length - 1);
? cpus.length - 1
: Math.min(Number(parallel) || 0, cpus.length - 1);
}

run(tasks, callback) {
Expand Down

0 comments on commit 9375646

Please sign in to comment.