fix new index example

This commit is contained in:
Iuri Matias 2017-12-08 11:04:28 -05:00
parent 3d36aaaeb3
commit 038f57e7d2
2 changed files with 53 additions and 0 deletions

View File

@ -254,6 +254,52 @@ Config.prototype.loadFile = function(files) {
var originalFiles = utils.filesMatchingPattern(files);
var readFiles = [];
// get embark.js object first
originalFiles.filter(function(file) {
return (file[0] === '$' || file.indexOf('.') >= 0);
}).filter(function(file) {
if (file === 'embark.js') {
if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) {
let web3Version = self.contractsConfig.versions["web3.js"];
if (web3Version && web3Version != currentWeb3Version) {
//if (false) {
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {
if (web3Version === "1.0.0-beta") {
return callback(fs.readFileSync(fs.embarkPath('js/web3-1.0.min.js')).toString());
} else {
let npm = new Npm({logger: self.logger});
npm.getPackageVersion('web3', web3Version, 'dist/web3.min.js', true, function(web3Content) {
callback(web3Content);
});
}
}}));
} else {
readFiles.push(new File({filename: 'web3.js', type: 'embark_internal', path: "js/web3.js"}));
}
}
if (self.storageConfig.enabled && (self.storageConfig.provider === 'ipfs' || self.storageConfig.available_providers.indexOf('ipfs') >= 0)) {
//until issues with the correct ipfs version to use are fixed
//readFiles.push(new File({filename: 'ipfs.js', type: 'embark_internal', path: "node_modules/ipfs-api/dist/index.min.js"}));
readFiles.push(new File({filename: 'ipfs.js', type: 'embark_internal', path: "js/ipfs.js"}));
}
if (self.communicationConfig.enabled && (self.communicationConfig.provider === 'orbit' || self.communicationConfig.available_providers.indexOf('orbit') >= 0)) {
readFiles.push(new File({filename: 'orbit.js', type: 'embark_internal', path: "node_modules/orbit-db/dist/orbitdb.min.js"}));
}
readFiles.push(new File({filename: 'embark.js', type: 'embark_internal', path: "js/build/embark.bundle.js"}));
}
if (file === '$EMBARK_JS') {
readFiles.push(new File({filename: '$EMBARK_JS', type: 'embark_internal', path: "js/build/embark.bundle.js"}));
}
//if (file === "web3.js") {
// readFiles.push(new File({filename: 'web3.js', type: 'embark_internal', path: "js/web3.js"));
//}
});
// get plugins
var filesFromPlugins = [];
@ -290,6 +336,8 @@ Config.prototype.loadFile = function(files) {
return;
} else if (file.indexOf("web3") === 0) {
return;
} else if (file.indexOf("embark") >= 0) {
return;
//} else if (file === 'abi.js') {
// readFiles.push({filename: file, content: "", path: file});
} else {
@ -314,6 +362,10 @@ Config.prototype.loadFile = function(files) {
console.log("MyLib Detected!");
return callback(null, "{foo: 'hello'}");
}
if (request == "Embark/EmbarkJS") {
console.log("EmbarkJS Detected!");
return callback(null, "{foo: 'hello'}");
}
callback();
},
module: {

View File

@ -2,6 +2,7 @@
<head>
<title>Embark - SimpleStorage Demo</title>
<link rel="stylesheet" href="css/app.css">
<script src="js/embark.js"></script>
<script src="js/new_app.js"></script>
</head>
<body class="container">