From a3f8c809a0e2f60453ef0e269c01d1516b59ac63 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 10 May 2018 13:28:12 -0400 Subject: [PATCH] add queue for changes to do only one file build at the time --- lib/core/engine.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index 69f22595..bef11c74 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -8,7 +8,8 @@ const CodeGenerator = require('../contracts/code_generator.js'); const ServicesMonitor = require('./services_monitor.js'); const Watch = require('../pipeline/watch.js'); const LibraryManager = require('../versions/library_manager.js'); -let Pipeline = require('../pipeline/pipeline.js'); +const Pipeline = require('../pipeline/pipeline.js'); +const async = require('async'); class Engine { constructor(options) { @@ -142,11 +143,17 @@ class Engine { normalizeInput: this.normalizeInput, plugins: this.plugins }); + + const queue = async.queue((task, callback) => { + pipeline.build(task.abi, task.contractsJSON, task.path, callback); + }, 1); + this.events.on('code-generator-ready', function () { self.events.request('code', function (abi, contractsJSON) { self.currentAbi = abi; self.contractsJSON = contractsJSON; - pipeline.build(abi, contractsJSON, null, function() { + + queue.push({abi, contractsJSON, path: null}, () => { if (self.watch) { self.watch.restart(); // Necessary because changing a file while it is writing can stop it from being watched }