From b473d68a1ee7ced34ee0b39069cbb800919bbf22 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 27 Jun 2017 18:18:29 -0400 Subject: [PATCH] include specific contract config given contract name --- lib/core/config.js | 8 +++++--- lib/pipeline/pipeline.js | 12 ++++++++++-- test_app/app/js/token_test.js | 0 test_app/embark.json | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 test_app/app/js/token_test.js diff --git a/lib/core/config.js b/lib/core/config.js index c87b6761..26dbb3c3 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -278,14 +278,16 @@ Config.prototype.loadFiles = function(files) { // get user files originalFiles.filter(function(file) { - return file.indexOf('.') >= 0; - }).filter(function(file) { if (file === 'embark.js') { return; } else if (file === 'abi.js') { readFiles.push({filename: file, content: "", path: file}); } 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}); + } } }); diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index d5af6cfb..9c7d60f3 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -13,6 +13,9 @@ class Pipeline { build(abi, contractsJSON, path) { let self = this; + + this.buildContracts(contractsJSON); + for (let targetFile in this.assetFiles) { let contentFiles = this.assetFiles[targetFile].map(file => { @@ -20,7 +23,13 @@ class 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}; } else if (file.filename === 'abi.js') { return {content: abi, filename: file.filename, path: file.path, modified: true}; @@ -77,7 +86,6 @@ class Pipeline { } } - this.buildContracts(contractsJSON); } buildContracts(contractsJSON) { diff --git a/test_app/app/js/token_test.js b/test_app/app/js/token_test.js new file mode 100644 index 00000000..e69de29b diff --git a/test_app/embark.json b/test_app/embark.json index 0dd46dd1..5bfb7a79 100644 --- a/test_app/embark.json +++ b/test_app/embark.json @@ -7,6 +7,7 @@ "js/embark.js": ["embark.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/token.js": ["$Token", "app/js/token_test.js"], "index.html": "app/index.html", "test.html": "app/test.html", "test2.html": "app/test2.html"