include specific contract config given contract name

This commit is contained in:
Iuri Matias 2017-06-27 20:27:24 -04:00
parent b473d68a1e
commit 4f90e62790
1 changed files with 11 additions and 3 deletions

View File

@ -23,11 +23,9 @@ class Pipeline {
let pipelinePlugins = this.plugins.getPluginsFor('pipeline');
self.logger.info("==> " + file.filename);
if (file.filename[0] === '$') {
let contractName = file.filename.substr(1);
let contractContent = fs.readFileSync('dist/contracts/' + contractName + '.json').toString();
return {content: contractContent, filename: contractName + ".js", path: file.path, modified: true};
return {content: this.buildContractJS(contractName), filename: contractName + ".js", path: file.path, modified: true};
}
else if (file.filename === 'embark.js') {
return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true};
@ -96,6 +94,16 @@ class Pipeline {
fs.writeJSONSync(this.buildDir + 'contracts/' + className + ".json", contract, {spaces: 2});
}
}
buildContractJS(contractName) {
let contractJSON = fs.readFileSync('dist/contracts/' + contractName + '.json').toString();
let contractCode = "";
contractCode += contractName + "JSONConfig = " + contractJSON + ";\n";
contractCode += contractName + " = new EmbarkJS.Contract(" + contractName + "JSONConfig);\n";
return contractCode;
}
}
module.exports = Pipeline;