Skip to content
This repository was archived by the owner on Apr 18, 2021. It is now read-only.

Commit

Permalink
fix: #80 adjust findImports
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudinertia committed Jan 28, 2019
1 parent a7212c5 commit 698b58a
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions packages/vvisp-utils/src/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,28 @@ module.exports = async function(filePath, silent) {

function findImports(filePath) {
// find recursively to find .sol file
const fileName = `${path.parse(filePath).name}.sol`;
const fileFound = new ff(fileName);
if (fileFound.length > 0) {
try {
return {
contents: fs.readFileSync(path.join('./', `${fileFound[0]}`), 'utf8')
contents: fs.readFileSync(path.join('./', filePath), 'utf8')
};
} else {
// find .sol file from node_modules
const nodeModules = findNodeModules();
for (let modulePath of nodeModules) {
if (fs.existsSync(path.join(modulePath, filePath)))
return {
contents: fs.readFileSync(path.join(modulePath, filePath), 'utf8')
};
} catch (e) {
const fileName = `${path.parse(filePath).name}.sol`;
const fileFound = new ff(fileName);
if (fileFound.length > 0) {
return {
contents: fs.readFileSync(path.join('./', `${fileFound[0]}`), 'utf8')
};
} else {
// find .sol file from node_modules
const nodeModules = findNodeModules();
for (let modulePath of nodeModules) {
if (fs.existsSync(path.join(modulePath, filePath)))
return {
contents: fs.readFileSync(path.join(modulePath, filePath), 'utf8')
};
}
throw 'module not found';
}
throw 'module not found';
}
}

Expand Down

0 comments on commit 698b58a

Please # to comment.