include specific contract config given contract name
This commit is contained in:
parent
b473d68a1e
commit
4f90e62790
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue