add queue for changes to do only one file build at the time

This commit is contained in:
Jonathan Rainville 2018-05-10 13:28:12 -04:00
parent a35ce6f73e
commit a3f8c809a0

View File

@ -8,7 +8,8 @@ const CodeGenerator = require('../contracts/code_generator.js');
const ServicesMonitor = require('./services_monitor.js'); const ServicesMonitor = require('./services_monitor.js');
const Watch = require('../pipeline/watch.js'); const Watch = require('../pipeline/watch.js');
const LibraryManager = require('../versions/library_manager.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 { class Engine {
constructor(options) { constructor(options) {
@ -142,11 +143,17 @@ class Engine {
normalizeInput: this.normalizeInput, normalizeInput: this.normalizeInput,
plugins: this.plugins 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 () { this.events.on('code-generator-ready', function () {
self.events.request('code', function (abi, contractsJSON) { self.events.request('code', function (abi, contractsJSON) {
self.currentAbi = abi; self.currentAbi = abi;
self.contractsJSON = contractsJSON; self.contractsJSON = contractsJSON;
pipeline.build(abi, contractsJSON, null, function() {
queue.push({abi, contractsJSON, path: null}, () => {
if (self.watch) { if (self.watch) {
self.watch.restart(); // Necessary because changing a file while it is writing can stop it from being watched self.watch.restart(); // Necessary because changing a file while it is writing can stop it from being watched
} }