mirror of https://github.com/embarklabs/embark.git
Merge pull request #415 from embark-framework/features/cargo
Add a cargo to not run file write for each file
This commit is contained in:
commit
256276c884
|
@ -146,16 +146,9 @@ class Engine {
|
||||||
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;
|
pipeline.build(abi, contractsJSON, null, () => {
|
||||||
self.contractsJSON = contractsJSON;
|
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
@ -168,7 +161,7 @@ class Engine {
|
||||||
codeGeneratorService(_options) {
|
codeGeneratorService(_options) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
let generateCode = function (contractsManager) {
|
const generateCode = function (contractsManager) {
|
||||||
let codeGenerator = new CodeGenerator({
|
let codeGenerator = new CodeGenerator({
|
||||||
blockchainConfig: self.config.blockchainConfig,
|
blockchainConfig: self.config.blockchainConfig,
|
||||||
contractsConfig: self.config.contractsConfig,
|
contractsConfig: self.config.contractsConfig,
|
||||||
|
@ -183,9 +176,17 @@ class Engine {
|
||||||
self.events.emit('code-generator-ready');
|
self.events.emit('code-generator-ready');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
this.events.on('contractsDeployed', generateCode);
|
const cargo = async.cargo((tasks, callback) => {
|
||||||
this.events.on('blockchainDisabled', generateCode);
|
generateCode(tasks[tasks.length - 1].contractsManager);
|
||||||
this.events.on('asset-changed', generateCode);
|
self.events.once('outputDone', callback);
|
||||||
|
});
|
||||||
|
const addToCargo = function (contractsManager) {
|
||||||
|
cargo.push({contractsManager});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.events.on('contractsDeployed', addToCargo);
|
||||||
|
this.events.on('blockchainDisabled', addToCargo);
|
||||||
|
this.events.on('asset-changed', addToCargo);
|
||||||
}
|
}
|
||||||
|
|
||||||
deploymentService(options) {
|
deploymentService(options) {
|
||||||
|
@ -223,18 +224,22 @@ class Engine {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.events.on('file-event', function (fileType) {
|
this.events.on('file-event', function (fileType) {
|
||||||
// TODO: still need to redeploy contracts because the original contracts
|
clearTimeout(self.fileTimeout);
|
||||||
// config is being corrupted
|
self.fileTimeout = setTimeout(() => {
|
||||||
if (fileType === 'asset') {
|
// TODO: still need to redeploy contracts because the original contracts
|
||||||
self.events.emit('asset-changed', self.contractsManager);
|
// config is being corrupted
|
||||||
}
|
if (fileType === 'asset') {
|
||||||
// TODO: for now need to deploy on asset chanes as well
|
// Throttle file changes so we re-write only once for all files
|
||||||
// because the contractsManager config is corrupted after a deploy
|
self.events.emit('asset-changed', self.contractsManager);
|
||||||
if (fileType === 'contract' || fileType === 'config') {
|
}
|
||||||
self.config.reloadConfig();
|
// TODO: for now need to deploy on asset changes as well
|
||||||
self.deployManager.deployContracts(function () {
|
// because the contractsManager config is corrupted after a deploy
|
||||||
});
|
if (fileType === 'contract' || fileType === 'config') {
|
||||||
}
|
self.config.reloadConfig();
|
||||||
|
self.deployManager.deployContracts(function () {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue