include specific contract config given contract name

This commit is contained in:
Iuri Matias 2017-06-27 18:18:29 -04:00
parent 32a8c411a7
commit b473d68a1e
4 changed files with 16 additions and 5 deletions

View File

@ -278,14 +278,16 @@ Config.prototype.loadFiles = function(files) {
// get user files // get user files
originalFiles.filter(function(file) { originalFiles.filter(function(file) {
return file.indexOf('.') >= 0;
}).filter(function(file) {
if (file === 'embark.js') { if (file === 'embark.js') {
return; return;
} else if (file === 'abi.js') { } else if (file === 'abi.js') {
readFiles.push({filename: file, content: "", path: file}); readFiles.push({filename: file, content: "", path: file});
} else { } else {
readFiles.push({filename: file, content: fs.readFileSync(file).toString(), path: file}); if (file.indexOf('.') >= 0) {
readFiles.push({filename: file, content: fs.readFileSync(file).toString(), path: file});
} else if (file[0] === '$') {
readFiles.push({filename: file, content: "", path: file});
}
} }
}); });

View File

@ -13,6 +13,9 @@ class Pipeline {
build(abi, contractsJSON, path) { build(abi, contractsJSON, path) {
let self = this; let self = this;
this.buildContracts(contractsJSON);
for (let targetFile in this.assetFiles) { for (let targetFile in this.assetFiles) {
let contentFiles = this.assetFiles[targetFile].map(file => { let contentFiles = this.assetFiles[targetFile].map(file => {
@ -20,7 +23,13 @@ class Pipeline {
let pipelinePlugins = this.plugins.getPluginsFor('pipeline'); let pipelinePlugins = this.plugins.getPluginsFor('pipeline');
if (file.filename === 'embark.js') { 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};
}
else if (file.filename === 'embark.js') {
return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true}; return {content: file.content + "\n" + abi, filename: file.filename, path: file.path, modified: true};
} else if (file.filename === 'abi.js') { } else if (file.filename === 'abi.js') {
return {content: abi, filename: file.filename, path: file.path, modified: true}; return {content: abi, filename: file.filename, path: file.path, modified: true};
@ -77,7 +86,6 @@ class Pipeline {
} }
} }
this.buildContracts(contractsJSON);
} }
buildContracts(contractsJSON) { buildContracts(contractsJSON) {

View File

View File

@ -7,6 +7,7 @@
"js/embark.js": ["embark.js"], "js/embark.js": ["embark.js"],
"js/abi.js": "abi.js", "js/abi.js": "abi.js",
"js/test.js": ["embark.js", "app/js/_vendor/jquery.min.js", "app/js/_vendor/async.min.js", "app/js/test.js"], "js/test.js": ["embark.js", "app/js/_vendor/jquery.min.js", "app/js/_vendor/async.min.js", "app/js/test.js"],
"js/token.js": ["$Token", "app/js/token_test.js"],
"index.html": "app/index.html", "index.html": "app/index.html",
"test.html": "app/test.html", "test.html": "app/test.html",
"test2.html": "app/test2.html" "test2.html": "app/test2.html"