add support for embark_js directive

This commit is contained in:
Iuri Matias 2017-07-03 18:54:31 -04:00
parent 0e904bba33
commit 0991a87b73
3 changed files with 8 additions and 2 deletions

View File

@ -229,7 +229,7 @@ Config.prototype.loadFiles = function(files) {
// get embark.js object first // get embark.js object first
originalFiles.filter(function(file) { originalFiles.filter(function(file) {
return file.indexOf('.') >= 0; return (file[0] === '$' || file.indexOf('.') >= 0);
}).filter(function(file) { }).filter(function(file) {
if (file === 'embark.js') { if (file === 'embark.js') {
@ -249,6 +249,9 @@ Config.prototype.loadFiles = function(files) {
readFiles.push({filename: 'embark.js', content: fs.readFileSync(fs.embarkPath("js/build/embark.bundle.js")).toString(), path: fs.embarkPath("js/build/embark.bundle.js")}); readFiles.push({filename: 'embark.js', content: fs.readFileSync(fs.embarkPath("js/build/embark.bundle.js")).toString(), path: fs.embarkPath("js/build/embark.bundle.js")});
} }
if (file === '$EMBARK_JS') {
readFiles.push({filename: '$EMBARK_JS', content: fs.readFileSync(fs.embarkPath("js/build/embark.bundle.js")).toString(), path: fs.embarkPath("js/build/embark.bundle.js")});
}
if (file.indexOf("web3-") === 0) { if (file.indexOf("web3-") === 0) {
let web3Version = file.split('web3-')[1].split(".js")[0]; let web3Version = file.split('web3-')[1].split(".js")[0];
npm.getPackageVersion('web3', web3Version, function(web3Content) { npm.getPackageVersion('web3', web3Version, function(web3Content) {

View File

@ -25,6 +25,8 @@ class Pipeline {
if (file.filename === "$ALL_CONTRACTS") { if (file.filename === "$ALL_CONTRACTS") {
return {content: abi, filename: file.filename, path: file.path, modified: true}; return {content: abi, filename: file.filename, path: file.path, modified: true};
} else if (file.filename === "$EMBARK_JS") {
return {content: file.content, filename: "embark.js", path: file.path, modified: true};
} else if (file.filename[0] === '$') { } else if (file.filename[0] === '$') {
let contractName = file.filename.substr(1); let contractName = file.filename.substr(1);
return {content: this.buildContractJS(contractName), filename: contractName + ".js", path: file.path, modified: true}; return {content: this.buildContractJS(contractName), filename: contractName + ".js", path: file.path, modified: true};

View File

@ -13,7 +13,8 @@
"test2.html": "app/test2.html", "test2.html": "app/test2.html",
"js/myweb3.js": "web3-0.18.js", "js/myweb3.js": "web3-0.18.js",
"js/web3.js": "web3.js", "js/web3.js": "web3.js",
"js/all_contracts.js": "$ALL_CONTRACTS" "js/all_contracts.js": "$ALL_CONTRACTS",
"js/only_embark.js": "$EMBARK_JS"
}, },
"buildDir": "dist/", "buildDir": "dist/",
"config": "config/", "config": "config/",