Skip to content

Commit

Permalink
fix for directory lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Mar 14, 2021
1 parent 99dc458 commit ab00f23
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/utils/parse-fs-inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ export default async function(fsInputs=[], initialFsTree={}, callback=async () =

try {
const entry = await fs.stat(fsReference);
const targetPath = `${process.cwd()}/${fsReference}`;

if (entry.isFile()) { // handle what to do when its .ts
let targetPath = `${process.cwd()}/${fsReference}`;

if (!fsTree[targetPath]) {
let treeEntry = {
targetLine: null,
Expand All @@ -32,27 +31,31 @@ export default async function(fsInputs=[], initialFsTree={}, callback=async () =

return Object.assign(fsTree, { [`${targetPath}`]: treeEntry });
}

return fsTree;
} else if (entry.isDirectory()) {
let targetFiles = config.browser ? ['js', 'ts'] : ['js'];
let fileNames = await recursiveFileLookup(`${projectRoot}/src`, targetFiles);
let fileNames = await recursiveFileLookup(targetPath, targetFiles);

fileNames.forEach(async (fileName) => {
if (!fsTree[targetPath]) {
return fileNames.reduce(async (result, fileName) => {
if (!fsTree[fileName]) {
let treeEntry = {
targetLine: null,
originalContent: null,
transpiledContent: null,
executed: false
}

await callback(targetPath, treeEntry);
await callback(fileName, treeEntry);

return Object.assign(fsTree, { [`${targetPath}`]: treeEntry });
return Object.assign(fsTree, { [`${fileName}`]: treeEntry });
}
});

return fsTree;
}, fsTree);
}
} catch (error) {
console.log(error);
console.error(error);

return process.exit(1);
}
Expand Down

0 comments on commit ab00f23

Please sign in to comment.