Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
fix(uglify/Runner): cpus length in a chroot environment (`os.cpus()…
Browse files Browse the repository at this point in the history
…`) (#341)
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Aug 14, 2018
1 parent c67566e commit 6d9c36f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/uglify/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default class Runner {
constructor(options = {}) {
const { cache, parallel } = options;
this.cacheDir = cache === true ? findCacheDir({ name: 'uglifyjs-webpack-plugin' }) : cache;
this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1);
// In some cases cpus() returns undefined
// https://github.com/nodejs/node/issues/19022
const cpus = (os.cpus() || { length: 1 });
this.maxConcurrentWorkers = parallel === true ? cpus.length - 1 : Math.min(Number(parallel) || 0, cpus.length - 1);
}

runTasks(tasks, callback) {
Expand Down

0 comments on commit 6d9c36f

Please sign in to comment.