refactor findImports

This commit is contained in:
Iuri Matias 2018-04-12 17:57:55 -04:00
parent db61e355c1
commit e0ab9cbde4
1 changed files with 6 additions and 8 deletions

View File

@ -4,15 +4,13 @@ let fs = require('fs-extra');
let path = require('path'); let path = require('path');
function findImports(filename) { function findImports(filename) {
console.dir(filename); if (fs.existsSync(filename)) {
if (!fs.existsSync(filename)) { return {contents: fs.readFileSync(filename).toString()};
if (fs.existsSync(path.join('./node_modules/', filename))) {
return {contents: fs.readFileSync(path.join('./node_modules/', filename)).toString()};
} else {
return {error: 'File not found'};
}
} }
return {contents: fs.readFileSync(filename).toString()}; if (fs.existsSync(path.join('./node_modules/', filename))) {
return {contents: fs.readFileSync(path.join('./node_modules/', filename)).toString()};
}
return {error: 'File not found'};
} }
process.on('message', function (msg) { process.on('message', function (msg) {