use es string templates

This commit is contained in:
Iuri Matias 2018-08-31 16:49:47 -04:00
parent 9cd3cb6891
commit 15467e6f49

View File

@ -303,7 +303,7 @@ class CodeGenerator {
},
function getImports(web3Location, next) {
web3Location = web3Location.replace(/\\/g, '/'); // Import paths must always have forward slashes
code += "\nimport Web3 from '" + web3Location + "';\n";
code += `\nimport Web3 from '${web3Location}';\n`;
code += "\nimport web3 from 'Embark/web3';\n";
code += "\nimport IpfsApi from 'ipfs-api';\n";
@ -339,9 +339,9 @@ class CodeGenerator {
let contractCode = "";
contractCode += "import web3 from 'Embark/web3';\n";
contractCode += "import EmbarkJS from 'Embark/EmbarkJS';\n";
contractCode += "let " + contractName + "JSONConfig = " + JSON.stringify(contractJSON) + ";\n";
contractCode += contractName + "JSONConfig.web3 = web3;\n";
contractCode += "let " + contractName + " = new EmbarkJS.Blockchain.Contract(" + contractName + "JSONConfig);\n";
contractCode += `let ${contractName}JSONConfig = ${JSON.stringify(contractJSON)};\n`;
contractCode += `${contractName}JSONConfig.web3 = web3;\n`;
contractCode += `let ${contractName} = new EmbarkJS.Blockchain.Contract(${contractName}JSONConfig);\n`;
contractCode += "export default " + contractName + ";\n";
cb(contractCode);
@ -364,7 +364,7 @@ class CodeGenerator {
},
function getImports(web3Location, next) {
web3Location = web3Location.replace(/\\/g, '/'); // Import paths must always have forward slashes
code += "\nimport Web3 from '" + web3Location + "';\n";
code += `\nimport Web3 from '${web3Location}';\n`;
code += "\nglobal.Web3 = Web3;\n";
code += "\n if (typeof web3 === 'undefined') {";