Merge pull request #821 from embark-framework/bug_fix/double-import
Fix double http import
This commit is contained in:
commit
53e3136ac6
|
@ -24,10 +24,11 @@ class File {
|
||||||
// Only supported in Solidity
|
// Only supported in Solidity
|
||||||
return callback(null, content);
|
return callback(null, content);
|
||||||
}
|
}
|
||||||
const regex = /import ["|']([-a-zA-Z0-9@:%_+.~#?&\/=]+)["|'];/g;
|
const regex = /import ["']([-a-zA-Z0-9@:%_+.~#?&\/=]+)["'];/g;
|
||||||
let matches;
|
let matches;
|
||||||
const filesToDownload = [];
|
const filesToDownload = [];
|
||||||
const pathWithoutFile = path.dirname(self.path);
|
const pathWithoutFile = path.dirname(self.path);
|
||||||
|
let newContent = content;
|
||||||
while ((matches = regex.exec(content))) {
|
while ((matches = regex.exec(content))) {
|
||||||
const httpFileObj = utils.getExternalContractUrl(matches[1]);
|
const httpFileObj = utils.getExternalContractUrl(matches[1]);
|
||||||
const fileObj = {
|
const fileObj = {
|
||||||
|
@ -36,7 +37,7 @@ class File {
|
||||||
};
|
};
|
||||||
if (httpFileObj) {
|
if (httpFileObj) {
|
||||||
// Replace http import by filePath import in content
|
// Replace http import by filePath import in content
|
||||||
content = content.replace(matches[1], httpFileObj.filePath);
|
newContent = newContent.replace(matches[1], httpFileObj.filePath);
|
||||||
|
|
||||||
fileObj.fileRelativePath = httpFileObj.filePath;
|
fileObj.fileRelativePath = httpFileObj.filePath;
|
||||||
fileObj.url = httpFileObj.url;
|
fileObj.url = httpFileObj.url;
|
||||||
|
@ -49,7 +50,7 @@ class File {
|
||||||
|
|
||||||
if (self.downloadedImports) {
|
if (self.downloadedImports) {
|
||||||
// We already parsed this file
|
// We already parsed this file
|
||||||
return callback(null, content);
|
return callback(null, newContent);
|
||||||
}
|
}
|
||||||
self.downloadedImports = true;
|
self.downloadedImports = true;
|
||||||
async.each(filesToDownload, ((fileObj, eachCb) => {
|
async.each(filesToDownload, ((fileObj, eachCb) => {
|
||||||
|
@ -57,7 +58,7 @@ class File {
|
||||||
eachCb();
|
eachCb();
|
||||||
});
|
});
|
||||||
}), (err) => {
|
}), (err) => {
|
||||||
callback(err, content);
|
callback(err, newContent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
pragma solidity ^0.4.17;
|
pragma solidity ^0.4.17;
|
||||||
|
|
||||||
import "https://github.com/embark-framework/embark/blob/develop/test_apps/contracts_app/contracts/ownable.sol";
|
import "https://github.com/embark-framework/embark/blob/develop/test_apps/contracts_app/contracts/ownable.sol";
|
||||||
|
import "https://github.com/embark-framework/embark/blob/develop/test_apps/contracts_app/contracts/contract_args.sol";
|
||||||
|
|
||||||
|
|
||||||
contract SimpleStorageWithHttpImport is Ownable {
|
contract SimpleStorageWithHttpImport is Ownable {
|
||||||
|
|
Loading…
Reference in New Issue