mirror of https://github.com/embarklabs/embark.git
feat(embark/generation): remove generation of web3instance.js
This commit is contained in:
parent
bd9fc6683a
commit
3b0a2b9b3e
|
@ -312,7 +312,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 'Embark/web3';\n";
|
||||
code += `\nglobal.Web3 = Web3;`;
|
||||
code += "\nimport IpfsApi from 'ipfs-api';\n";
|
||||
|
||||
next();
|
||||
|
@ -376,37 +376,6 @@ class CodeGenerator {
|
|||
|
||||
this.generateArtifact(contractCode, contractName + '.js', constants.dappConfig.contractsJs, cb);
|
||||
}
|
||||
|
||||
buildWeb3JS(cb) {
|
||||
const self = this;
|
||||
let code = "";
|
||||
|
||||
async.waterfall([
|
||||
function getWeb3Location(next) {
|
||||
self.events.request("version:get:web3", function(web3Version) {
|
||||
if (web3Version === "1.0.0-beta") {
|
||||
return next(null, require.resolve("web3", {paths: [self.fs.embarkPath("node_modules")]}));
|
||||
}
|
||||
self.events.request("version:getPackageLocation", "web3", web3Version, function(err, location) {
|
||||
return next(null, self.fs.dappPath(location));
|
||||
});
|
||||
});
|
||||
},
|
||||
function getImports(web3Location, next) {
|
||||
web3Location = web3Location.replace(/\\/g, '/'); // Import paths must always have forward slashes
|
||||
code += `\nimport Web3 from '${web3Location}';\n`;
|
||||
code += "\nglobal.Web3 = Web3;\n";
|
||||
|
||||
code += "\nconsole.log('GLOBAL WEB3', global.web3);";
|
||||
code += "\nif (typeof web3 === 'undefined') {";
|
||||
code += "\n var web3 = new Web3();";
|
||||
code += "\n}";
|
||||
|
||||
code += "\nexport default web3;\n";
|
||||
next(null, code);
|
||||
}
|
||||
], cb);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CodeGenerator;
|
||||
|
|
|
@ -154,7 +154,6 @@ class Pipeline {
|
|||
self.events.request('placeholder:build', next);
|
||||
},
|
||||
(next) => self.buildContracts(next),
|
||||
(next) => self.buildWeb3JS(next),
|
||||
function createImportList(next) {
|
||||
importsList["Embark/EmbarkJS"] = self.fs.dappPath(self.embarkConfig.generationDir, constants.dappConfig.embarkjs);
|
||||
importsList["Embark/web3"] = self.fs.dappPath(".embark", 'web3_instance.js');
|
||||
|
@ -372,21 +371,6 @@ class Pipeline {
|
|||
], cb);
|
||||
}
|
||||
|
||||
buildWeb3JS(cb) {
|
||||
const self = this;
|
||||
async.waterfall([
|
||||
function makeDirectory(next) {
|
||||
self.fs.mkdirp(self.fs.dappPath(".embark"), err => next(err));
|
||||
},
|
||||
function getWeb3Code(next) {
|
||||
self.events.request('code-generator:web3js', next);
|
||||
},
|
||||
function writeFile(code, next) {
|
||||
self.fs.writeFile(self.fs.dappPath(".embark", 'web3_instance.js'), code, next);
|
||||
}
|
||||
], cb);
|
||||
}
|
||||
|
||||
runPlugins(file, fileContent, fileCb) {
|
||||
const self = this;
|
||||
if (self.pipelinePlugins.length <= 0) {
|
||||
|
|
Loading…
Reference in New Issue