Add `--threads=#` option for setting max threads

Make grunt NODE_ENV development by default
v1.18.x
Peter Jaszkowiak 8 years ago
parent 62546bc4fd
commit 2a9cdb7be2

@ -8,6 +8,8 @@ var initWorker;
var incomplete = [];
var running = 0;
env.NODE_ENV = env.NODE_ENV || 'development';
module.exports = function (grunt) {
var args = [];
var initArgs = ['--build'];

@ -180,6 +180,11 @@ function build(targets, callback) {
async.series([
beforeBuild,
function (next) {
var threads = parseInt(nconf.get('threads'), 10);
if (threads) {
require('./minifier').maxThreads = threads - 1;
}
var parallel = !nconf.get('series');
if (parallel) {
winston.info('[build] Building in parallel mode');

@ -41,9 +41,21 @@ function setupDebugging() {
var pool = [];
var free = [];
Minifier.maxThreads = os.cpus().length - 1;
var maxThreads = 0;
Object.defineProperty(Minifier, 'maxThreads', {
get: function () {
return maxThreads;
},
set: function (val) {
maxThreads = val;
winston.verbose('[minifier] utilizing a maximum of ' + maxThreads + ' additional threads');
},
configurable: true,
enumerable: true,
});
winston.verbose('[minifier] utilizing a maximum of ' + Minifier.maxThreads + ' additional threads');
Minifier.maxThreads = os.cpus().length - 1;
Minifier.killAll = function () {
pool.forEach(function (child) {

Loading…
Cancel
Save