fix(@embark/cmd): output contract json

This fix ensures that `embark build --contracts` outputs the contracts
the same way a normal build would.
This commit is contained in:
Andre Medeiros 2018-11-20 14:46:59 -05:00 committed by Iuri Matias
parent 46e351ed36
commit 4dca72368b
2 changed files with 13 additions and 10 deletions

View File

@ -213,10 +213,10 @@ class EmbarkController {
engine.startService("processManager");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("pipeline");
if (!options.onlyCompile) {
engine.startService("web3");
engine.startService("deployment", {onlyCompile: options.onlyCompile});
engine.startService("pipeline");
engine.startService("storage");
engine.startService("codeGenerator");
} else {
@ -226,12 +226,14 @@ class EmbarkController {
callback();
},
function buildOrBuildAndDeploy(callback) {
if (options.onlyCompile) {
engine.events.request('contracts:build', {}, err => callback(err));
} else {
// deploy:contracts will trigger a build as well
engine.events.request('deploy:contracts', err => callback(err));
}
if (options.onlyCompile)
return engine.events.request('contracts:build', {}, err => {
if(err !== undefined) return callback(err);
engine.events.request('pipeline:build:contracts', err => callback(err));
});
// deploy:contracts will trigger a build as well
engine.events.request('deploy:contracts', err => callback(err));
},
function waitForWriteFinish(callback) {
if (options.onlyCompile) {

View File

@ -22,6 +22,7 @@ class Pipeline {
this.isFirstBuild = true;
this.events.setCommandHandler('pipeline:build', (options, callback) => this.build(options, callback));
this.events.setCommandHandler('pipeline:build:contracts', callback => this.buildContracts(callback));
fs.removeSync(this.buildDir);
let plugin = this.plugins.createPlugin('deployment', {});
@ -34,7 +35,7 @@ class Pipeline {
} catch (error) {
return res.send({error: error.message});
}
const name = path.basename(req.query.path);
const content = fs.readFileSync(req.query.path, 'utf8');
res.send({name, content, path: req.query.path});
@ -51,7 +52,7 @@ class Pipeline {
} catch (error) {
return res.send({error: error.message});
}
fs.mkdirpSync(req.body.path);
const name = path.basename(req.body.path);
res.send({name, path: req.body.path});
@ -97,7 +98,7 @@ class Pipeline {
const walk = (dir, filelist = []) => fs.readdirSync(dir).map(name => {
let isRoot = rootPath === dir;
if (fs.statSync(path.join(dir, name)).isDirectory()) {
return {
return {
isRoot,
name,
dirname: dir,