From e6d8e18e083e1f5d2cb7f90dae616c3b9e75f4ac Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sun, 14 Feb 2016 23:32:55 +0800 Subject: [PATCH] improve module loading workaround --- backtest.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/backtest.js b/backtest.js index d75856e..50c055e 100644 --- a/backtest.js +++ b/backtest.js @@ -38,14 +38,8 @@ function writeText(filePath, data) { } function loadModule() { - try { - require('./src/htmlparser'); - return require('./src/htmlminifier').minify; - } - catch (e) { - require('./htmlparser'); - return require('./master').minify; - } + require('./src/htmlparser'); + return require('./src/htmlminifier').minify || global.minify; } function getOptions(fileName, options) { @@ -130,12 +124,11 @@ if (process.argv.length > 2) { var running = 0, ready = true; var progress = new Progress('[:bar] :etas', { width: 50, - total: commits.length + total: commits.length * 2 }); function fork() { if (commits.length && running < nThreads) { - progress.tick(1); var hash = commits.shift(); var task = child_process.fork('./backtest', { silent: true }); var error = ''; @@ -147,6 +140,7 @@ if (process.argv.length > 2) { }, 60000); task.on('message', function(data) { if (data === 'ready') { + progress.tick(1); ready = true; fork(); } @@ -154,6 +148,7 @@ if (process.argv.length > 2) { table[hash][data.name] = data.size; } }).on('exit', function() { + progress.tick(1); clearTimeout(id); if (error) { table[hash].error = error; -- 2.34.1