Skip to content

Commit

Permalink
fix processing files that have variable declaration without an initia…
Browse files Browse the repository at this point in the history
…lizer and fixing logs
  • Loading branch information
LeonOstrez committed Jul 14, 2023
1 parent 7334780 commit 3369b1a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pythagora",
"version": "0.0.76",
"version": "0.0.78",
"author": {
"name": "Zvonimir Sabljic",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ do
exit 0
elif [[ "${args[$i]}" == "--unit-tests" ]]
then
echo "${green}${bold}Generating unit tests...${reset}"
echo "${green}${bold}Starting generation of unit tests...${reset}"
PYTHAGORA_CONFIG="$@" node "${pythagora_dir}/src/scripts/unit.js"
exit 0
elif [[ "${args[$i]}" == "--export-setup" ]]
Expand Down
6 changes: 4 additions & 2 deletions src/helpers/unitTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function processFile(filePath, filesToProcess) {
if (importedFile && !filesToProcess.includes(importedFile)) {
filesToProcess.push(importedFile);
}
} else if (node.type === "VariableDeclaration" && node.declarations[0].init.type === "CallExpression" && node.declarations[0].init.callee.name === "require") {
} else if (node.type === "VariableDeclaration" && node.declarations.length > 0 && node.declarations[0].init && node.declarations[0].init.type === "CallExpression" && node.declarations[0].init.callee.name === "require") {
let importedFile = path.resolve(path.dirname(filePath), node.declarations[0].init.arguments[0].value);
importedFile = resolveFilePath(importedFile, extension);
if (importedFile && !filesToProcess.includes(importedFile)) {
Expand Down Expand Up @@ -365,12 +365,14 @@ async function generateTestsForDirectory(args, processingFunction = 'getUnitTest
API.checkForAPIKey();
queriedPath = path.resolve(pathToProcess);
rootPath = args.pythagora_root;
({ screen, spinner, scrollableContent } = initScreenForUnitTests());
console.log('Processing folder structure...');

await traverseDirectory(queriedPath, true, funcName, processingFunction);
processedFiles = [];
await traverseDirectory(queriedPath, true, funcName, processingFunction);
processedFiles = [];
console.log('Generating tests...');
({ screen, spinner, scrollableContent } = initScreenForUnitTests());
await traverseDirectory(queriedPath, false, funcName, processingFunction);

screen.destroy();
Expand Down

0 comments on commit 3369b1a

Please sign in to comment.